Skip to content

Commit

Permalink
mm/slab: Introduce kmem_buckets typedef
Browse files Browse the repository at this point in the history
Encapsulate the concept of a single set of kmem_caches that are used
for the kmalloc size buckets. Redefine kmalloc_caches as an array
of these buckets (for the different global cache buckets).

Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
  • Loading branch information
Kees Cook authored and Vlastimil Babka committed Jul 3, 2024
1 parent ad59baa commit 72e0fe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ enum kmalloc_cache_type {
NR_KMALLOC_TYPES
};

extern struct kmem_cache *
kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1];
typedef struct kmem_cache * kmem_buckets[KMALLOC_SHIFT_HIGH + 1];

extern kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES];

/*
* Define gfp bits that should not be set for KMALLOC_NORMAL.
Expand Down
3 changes: 1 addition & 2 deletions mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,7 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name,
return s;
}

struct kmem_cache *
kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1] __ro_after_init =
kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES] __ro_after_init =
{ /* initialization for https://llvm.org/pr42570 */ };
EXPORT_SYMBOL(kmalloc_caches);

Expand Down

0 comments on commit 72e0fe2

Please sign in to comment.