Skip to content

Commit

Permalink
remove unused flag KMC_KMEM
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrens committed Aug 4, 2020
1 parent a15c6f3 commit c0c3ae9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 81 deletions.
2 changes: 0 additions & 2 deletions include/os/linux/spl/sys/kmem_cache.h
Expand Up @@ -41,7 +41,6 @@ typedef enum kmc_bit {
KMC_BIT_NOMAGAZINE = 2, /* XXX: Unsupported */
KMC_BIT_NOHASH = 3, /* XXX: Unsupported */
KMC_BIT_QCACHE = 4, /* XXX: Unsupported */
KMC_BIT_KMEM = 5, /* Use kmem cache */
KMC_BIT_VMEM = 6, /* Use vmem cache */
KMC_BIT_KVMEM = 7, /* Use kvmalloc linux allocator */
KMC_BIT_SLAB = 8, /* Use Linux slab cache */
Expand Down Expand Up @@ -69,7 +68,6 @@ typedef enum kmem_cbrc {
#define KMC_NOMAGAZINE (1 << KMC_BIT_NOMAGAZINE)
#define KMC_NOHASH (1 << KMC_BIT_NOHASH)
#define KMC_QCACHE (1 << KMC_BIT_QCACHE)
#define KMC_KMEM (1 << KMC_BIT_KMEM)
#define KMC_VMEM (1 << KMC_BIT_VMEM)
#define KMC_KVMEM (1 << KMC_BIT_KVMEM)
#define KMC_SLAB (1 << KMC_BIT_SLAB)
Expand Down
1 change: 0 additions & 1 deletion include/sys/zfs_context.h
Expand Up @@ -402,7 +402,6 @@ void procfs_list_add(procfs_list_t *procfs_list, void *p);
#define KM_NOSLEEP UMEM_DEFAULT
#define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */
#define KMC_NODEBUG UMC_NODEBUG
#define KMC_KMEM 0x0
#define KMC_VMEM 0x0
#define KMC_KVMEM 0x0
#define kmem_alloc(_s, _f) umem_alloc(_s, _f)
Expand Down
57 changes: 6 additions & 51 deletions module/os/linux/spl/spl-kmem-cache.c
Expand Up @@ -112,17 +112,6 @@ module_param(spl_kmem_cache_slab_limit, uint, 0644);
MODULE_PARM_DESC(spl_kmem_cache_slab_limit,
"Objects less than N bytes use the Linux slab");

/*
* This value defaults to a threshold designed to avoid allocations which
* have been deemed costly by the kernel.
*/
unsigned int spl_kmem_cache_kmem_limit =
((1 << (PAGE_ALLOC_COSTLY_ORDER - 1)) * PAGE_SIZE) /
SPL_KMEM_CACHE_OBJ_PER_SLAB;
module_param(spl_kmem_cache_kmem_limit, uint, 0644);
MODULE_PARM_DESC(spl_kmem_cache_kmem_limit,
"Objects less than N bytes use the kmalloc");

/*
* The number of threads available to allocate new slabs for caches. This
* should not need to be tuned but it is available for performance analysis.
Expand Down Expand Up @@ -177,12 +166,7 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags)
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;

if (skc->skc_flags & KMC_KMEM) {
ASSERT(ISP2(size));
ptr = (void *)__get_free_pages(lflags, get_order(size));
} else {
ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);
}
ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);

/* Resulting allocated memory will be page aligned */
ASSERT(IS_P2ALIGNED(ptr, PAGE_SIZE));
Expand All @@ -205,12 +189,7 @@ kv_free(spl_kmem_cache_t *skc, void *ptr, int size)
if (current->reclaim_state)
current->reclaim_state->reclaimed_slab += size >> PAGE_SHIFT;

if (skc->skc_flags & KMC_KMEM) {
ASSERT(ISP2(size));
free_pages((unsigned long)ptr, get_order(size));
} else {
vfree(ptr);
}
vfree(ptr);
}

/*
Expand Down Expand Up @@ -606,28 +585,12 @@ spl_slab_size(spl_kmem_cache_t *skc, uint32_t *objs, uint32_t *size)
if (skc->skc_flags & KMC_OFFSLAB) {
tgt_objs = spl_kmem_cache_obj_per_slab;
tgt_size = P2ROUNDUP(sizeof (spl_kmem_slab_t), PAGE_SIZE);

if ((skc->skc_flags & KMC_KMEM) &&
(spl_obj_size(skc) > (SPL_MAX_ORDER_NR_PAGES * PAGE_SIZE)))
return (-ENOSPC);
} else {
sks_size = spl_sks_size(skc);
obj_size = spl_obj_size(skc);
max_size = (spl_kmem_cache_max_size * 1024 * 1024);
tgt_size = (spl_kmem_cache_obj_per_slab * obj_size + sks_size);

/*
* KMC_KMEM slabs are allocated by __get_free_pages() which
* rounds up to the nearest order. Knowing this the size
* should be rounded up to the next power of two with a hard
* maximum defined by the maximum allowed allocation order.
*/
if (skc->skc_flags & KMC_KMEM) {
max_size = SPL_MAX_ORDER_NR_PAGES * PAGE_SIZE;
tgt_size = MIN(max_size,
PAGE_SIZE * (1 << MAX(get_order(tgt_size) - 1, 1)));
}

if (tgt_size <= max_size) {
tgt_objs = (tgt_size - sks_size) / obj_size;
} else {
Expand Down Expand Up @@ -770,7 +733,6 @@ spl_magazine_destroy(spl_kmem_cache_t *skc)
* priv cache private data for ctor/dtor/reclaim
* vmp unused must be NULL
* flags
* KMC_KMEM Force SPL kmem backed cache
* KMC_VMEM Force SPL vmem backed cache
* KMC_KVMEM Force kvmem backed cache
* KMC_SLAB Force Linux slab backed cache
Expand Down Expand Up @@ -865,21 +827,14 @@ spl_kmem_cache_create(char *name, size_t size, size_t align,
* linuxslab) then select a cache type based on the object size
* and default tunables.
*/
if (!(skc->skc_flags & (KMC_KMEM | KMC_VMEM | KMC_SLAB | KMC_KVMEM))) {
if (!(skc->skc_flags & (KMC_VMEM | KMC_SLAB | KMC_KVMEM))) {
if (spl_kmem_cache_slab_limit &&
size <= (size_t)spl_kmem_cache_slab_limit) {
/*
* Objects smaller than spl_kmem_cache_slab_limit can
* use the Linux slab for better space-efficiency.
*/
skc->skc_flags |= KMC_SLAB;
} else if (spl_obj_size(skc) <= spl_kmem_cache_kmem_limit) {
/*
* Small objects, less than spl_kmem_cache_kmem_limit
* per object should use kmem because their slabs are
* small.
*/
skc->skc_flags |= KMC_KMEM;
} else {
/*
* All other objects are considered large and are
Expand All @@ -892,7 +847,7 @@ spl_kmem_cache_create(char *name, size_t size, size_t align,
/*
* Given the type of slab allocate the required resources.
*/
if (skc->skc_flags & (KMC_KMEM | KMC_VMEM | KMC_KVMEM)) {
if (skc->skc_flags & (KMC_VMEM | KMC_KVMEM)) {
rc = spl_slab_size(skc,
&skc->skc_slab_objs, &skc->skc_slab_size);
if (rc)
Expand Down Expand Up @@ -971,7 +926,7 @@ spl_kmem_cache_destroy(spl_kmem_cache_t *skc)
taskqid_t id;

ASSERT(skc->skc_magic == SKC_MAGIC);
ASSERT(skc->skc_flags & (KMC_KMEM | KMC_VMEM | KMC_KVMEM | KMC_SLAB));
ASSERT(skc->skc_flags & (KMC_VMEM | KMC_KVMEM | KMC_SLAB));

down_write(&spl_kmem_cache_sem);
list_del_init(&skc->skc_list);
Expand All @@ -993,7 +948,7 @@ spl_kmem_cache_destroy(spl_kmem_cache_t *skc)
*/
wait_event(wq, atomic_read(&skc->skc_ref) == 0);

if (skc->skc_flags & (KMC_KMEM | KMC_VMEM | KMC_KVMEM)) {
if (skc->skc_flags & (KMC_VMEM | KMC_KVMEM)) {
spl_magazine_destroy(skc);
spl_slab_reclaim(skc);
} else {
Expand Down
27 changes: 0 additions & 27 deletions module/os/linux/spl/spl-proc.c
Expand Up @@ -631,33 +631,6 @@ static struct ctl_table spl_kmem_table[] = {
.proc_handler = &proc_doulongvec_minmax,
},
#endif /* DEBUG_KMEM */
{
.procname = "slab_kmem_total",
.data = (void *)(KMC_KMEM | KMC_TOTAL),
.maxlen = sizeof (unsigned long),
.extra1 = &table_min,
.extra2 = &table_max,
.mode = 0444,
.proc_handler = &proc_doslab,
},
{
.procname = "slab_kmem_alloc",
.data = (void *)(KMC_KMEM | KMC_ALLOC),
.maxlen = sizeof (unsigned long),
.extra1 = &table_min,
.extra2 = &table_max,
.mode = 0444,
.proc_handler = &proc_doslab,
},
{
.procname = "slab_kmem_max",
.data = (void *)(KMC_KMEM | KMC_MAX),
.maxlen = sizeof (unsigned long),
.extra1 = &table_min,
.extra2 = &table_max,
.mode = 0444,
.proc_handler = &proc_doslab,
},
{
.procname = "slab_vmem_total",
.data = (void *)(KMC_VMEM | KMC_TOTAL),
Expand Down

0 comments on commit c0c3ae9

Please sign in to comment.