Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/slab: Introduce kmem_buckets typedef

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>

authored by

Kees Cook and committed by
Vlastimil Babka
72e0fe22 ad59baa3

+4 -4
+3 -2
include/linux/slab.h
··· 426 426 NR_KMALLOC_TYPES 427 427 }; 428 428 429 - extern struct kmem_cache * 430 - kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1]; 429 + typedef struct kmem_cache * kmem_buckets[KMALLOC_SHIFT_HIGH + 1]; 430 + 431 + extern kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES]; 431 432 432 433 /* 433 434 * Define gfp bits that should not be set for KMALLOC_NORMAL.
+1 -2
mm/slab_common.c
··· 654 654 return s; 655 655 } 656 656 657 - struct kmem_cache * 658 - kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1] __ro_after_init = 657 + kmem_buckets kmalloc_caches[NR_KMALLOC_TYPES] __ro_after_init = 659 658 { /* initialization for https://llvm.org/pr42570 */ }; 660 659 EXPORT_SYMBOL(kmalloc_caches); 661 660