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

mm/slab: remove CONFIG_SLOB code from slab common code

CONFIG_SLOB has been removed from Kconfig. Remove code and #ifdef's
specific to SLOB in the slab headers and common code.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Acked-by: Lorenzo Stoakes <lstoakes@gmail.com>
Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

-102
-39
include/linux/slab.h
··· 298 298 #endif 299 299 #endif 300 300 301 - #ifdef CONFIG_SLOB 302 - /* 303 - * SLOB passes all requests larger than one page to the page allocator. 304 - * No kmalloc array is necessary since objects of different sizes can 305 - * be allocated from the same page. 306 - */ 307 - #define KMALLOC_SHIFT_HIGH PAGE_SHIFT 308 - #define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) 309 - #ifndef KMALLOC_SHIFT_LOW 310 - #define KMALLOC_SHIFT_LOW 3 311 - #endif 312 - #endif 313 - 314 301 /* Maximum allocatable size */ 315 302 #define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_MAX) 316 303 /* Maximum size for which we actually use a slab cache */ ··· 353 366 NR_KMALLOC_TYPES 354 367 }; 355 368 356 - #ifndef CONFIG_SLOB 357 369 extern struct kmem_cache * 358 370 kmalloc_caches[NR_KMALLOC_TYPES][KMALLOC_SHIFT_HIGH + 1]; 359 371 ··· 444 458 } 445 459 static_assert(PAGE_SHIFT <= 20); 446 460 #define kmalloc_index(s) __kmalloc_index(s, true) 447 - #endif /* !CONFIG_SLOB */ 448 461 449 462 void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __alloc_size(1); 450 463 ··· 472 487 void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p); 473 488 int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, void **p); 474 489 475 - /* 476 - * Caller must not use kfree_bulk() on memory not originally allocated 477 - * by kmalloc(), because the SLOB allocator cannot handle this. 478 - */ 479 490 static __always_inline void kfree_bulk(size_t size, void **p) 480 491 { 481 492 kmem_cache_free_bulk(NULL, size, p); ··· 548 567 * Try really hard to succeed the allocation but fail 549 568 * eventually. 550 569 */ 551 - #ifndef CONFIG_SLOB 552 570 static __always_inline __alloc_size(1) void *kmalloc(size_t size, gfp_t flags) 553 571 { 554 572 if (__builtin_constant_p(size) && size) { ··· 563 583 } 564 584 return __kmalloc(size, flags); 565 585 } 566 - #else 567 - static __always_inline __alloc_size(1) void *kmalloc(size_t size, gfp_t flags) 568 - { 569 - if (__builtin_constant_p(size) && size > KMALLOC_MAX_CACHE_SIZE) 570 - return kmalloc_large(size, flags); 571 586 572 - return __kmalloc(size, flags); 573 - } 574 - #endif 575 - 576 - #ifndef CONFIG_SLOB 577 587 static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) 578 588 { 579 589 if (__builtin_constant_p(size) && size) { ··· 579 609 } 580 610 return __kmalloc_node(size, flags, node); 581 611 } 582 - #else 583 - static __always_inline __alloc_size(1) void *kmalloc_node(size_t size, gfp_t flags, int node) 584 - { 585 - if (__builtin_constant_p(size) && size > KMALLOC_MAX_CACHE_SIZE) 586 - return kmalloc_large_node(size, flags, node); 587 - 588 - return __kmalloc_node(size, flags, node); 589 - } 590 - #endif 591 612 592 613 /** 593 614 * kmalloc_array - allocate memory for an array.
-61
mm/slab.h
··· 51 51 }; 52 52 unsigned int __unused; 53 53 54 - #elif defined(CONFIG_SLOB) 55 - 56 - struct list_head slab_list; 57 - void *__unused_1; 58 - void *freelist; /* first free block */ 59 - long units; 60 - unsigned int __unused_2; 61 - 62 54 #else 63 55 #error "Unexpected slab allocator configured" 64 56 #endif ··· 64 72 #define SLAB_MATCH(pg, sl) \ 65 73 static_assert(offsetof(struct page, pg) == offsetof(struct slab, sl)) 66 74 SLAB_MATCH(flags, __page_flags); 67 - #ifndef CONFIG_SLOB 68 75 SLAB_MATCH(compound_head, slab_cache); /* Ensure bit 0 is clear */ 69 - #else 70 - SLAB_MATCH(compound_head, slab_list); /* Ensure bit 0 is clear */ 71 - #endif 72 76 SLAB_MATCH(_refcount, __page_refcount); 73 77 #ifdef CONFIG_MEMCG 74 78 SLAB_MATCH(memcg_data, memcg_data); ··· 188 200 return PAGE_SIZE << slab_order(slab); 189 201 } 190 202 191 - #ifdef CONFIG_SLOB 192 - /* 193 - * Common fields provided in kmem_cache by all slab allocators 194 - * This struct is either used directly by the allocator (SLOB) 195 - * or the allocator must include definitions for all fields 196 - * provided in kmem_cache_common in their definition of kmem_cache. 197 - * 198 - * Once we can do anonymous structs (C11 standard) we could put a 199 - * anonymous struct definition in these allocators so that the 200 - * separate allocations in the kmem_cache structure of SLAB and 201 - * SLUB is no longer needed. 202 - */ 203 - struct kmem_cache { 204 - unsigned int object_size;/* The original size of the object */ 205 - unsigned int size; /* The aligned/padded/added on size */ 206 - unsigned int align; /* Alignment as calculated */ 207 - slab_flags_t flags; /* Active flags on the slab */ 208 - const char *name; /* Slab name for sysfs */ 209 - int refcount; /* Use counter */ 210 - void (*ctor)(void *); /* Called on object slot creation */ 211 - struct list_head list; /* List of all slab caches on the system */ 212 - }; 213 - 214 - #endif /* CONFIG_SLOB */ 215 - 216 203 #ifdef CONFIG_SLAB 217 204 #include <linux/slab_def.h> 218 205 #endif ··· 237 274 unsigned int size; 238 275 } kmalloc_info[]; 239 276 240 - #ifndef CONFIG_SLOB 241 277 /* Kmalloc array related functions */ 242 278 void setup_kmalloc_cache_index_table(void); 243 279 void create_kmalloc_caches(slab_flags_t); ··· 248 286 int node, size_t orig_size, 249 287 unsigned long caller); 250 288 void __kmem_cache_free(struct kmem_cache *s, void *x, unsigned long caller); 251 - #endif 252 289 253 290 gfp_t kmalloc_fix_flags(gfp_t flags); 254 291 ··· 264 303 int slab_unmergeable(struct kmem_cache *s); 265 304 struct kmem_cache *find_mergeable(unsigned size, unsigned align, 266 305 slab_flags_t flags, const char *name, void (*ctor)(void *)); 267 - #ifndef CONFIG_SLOB 268 306 struct kmem_cache * 269 307 __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, 270 308 slab_flags_t flags, void (*ctor)(void *)); 271 309 272 310 slab_flags_t kmem_cache_flags(unsigned int object_size, 273 311 slab_flags_t flags, const char *name); 274 - #else 275 - static inline struct kmem_cache * 276 - __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, 277 - slab_flags_t flags, void (*ctor)(void *)) 278 - { return NULL; } 279 - 280 - static inline slab_flags_t kmem_cache_flags(unsigned int object_size, 281 - slab_flags_t flags, const char *name) 282 - { 283 - return flags; 284 - } 285 - #endif 286 312 287 313 static inline bool is_kmalloc_cache(struct kmem_cache *s) 288 314 { 289 - #ifndef CONFIG_SLOB 290 315 return (s->flags & SLAB_KMALLOC); 291 - #else 292 - return false; 293 - #endif 294 316 } 295 317 296 318 /* Legal flag mask for kmem_cache_create(), for various configurations */ ··· 578 634 } 579 635 #endif /* CONFIG_MEMCG_KMEM */ 580 636 581 - #ifndef CONFIG_SLOB 582 637 static inline struct kmem_cache *virt_to_cache(const void *obj) 583 638 { 584 639 struct slab *slab; ··· 626 683 } 627 684 628 685 void free_large_kmalloc(struct folio *folio, void *object); 629 - 630 - #endif /* CONFIG_SLOB */ 631 686 632 687 size_t __ksize(const void *objp); 633 688 ··· 718 777 memcg_slab_post_alloc_hook(s, objcg, flags, size, p); 719 778 } 720 779 721 - #ifndef CONFIG_SLOB 722 780 /* 723 781 * The slab lists for all objects. 724 782 */ ··· 764 824 for (__node = 0; __node < nr_node_ids; __node++) \ 765 825 if ((__n = get_node(__s, __node))) 766 826 767 - #endif 768 827 769 828 #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) 770 829 void dump_unreclaimable_slab(void);
-2
mm/slab_common.c
··· 625 625 EXPORT_SYMBOL_GPL(kmem_dump_obj); 626 626 #endif 627 627 628 - #ifndef CONFIG_SLOB 629 628 /* Create a cache during boot when no slab services are available yet */ 630 629 void __init create_boot_cache(struct kmem_cache *s, const char *name, 631 630 unsigned int size, slab_flags_t flags, ··· 1078 1079 return ret; 1079 1080 } 1080 1081 EXPORT_SYMBOL(kmalloc_node_trace); 1081 - #endif /* !CONFIG_SLOB */ 1082 1082 1083 1083 gfp_t kmalloc_fix_flags(gfp_t flags) 1084 1084 {