diff options
-rw-r--r-- | include/linux/slub_def.h | 19 | ||||
-rw-r--r-- | mm/slub.c | 16 |
2 files changed, 24 insertions, 11 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 2f5c16b1aacd..986e09dcfd8f 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -121,10 +121,23 @@ struct kmem_cache { | |||
121 | #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE) | 121 | #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE) |
122 | 122 | ||
123 | /* | 123 | /* |
124 | * Maximum kmalloc object size handled by SLUB. Larger object allocations | ||
125 | * are passed through to the page allocator. The page allocator "fastpath" | ||
126 | * is relatively slow so we need this value sufficiently high so that | ||
127 | * performance critical objects are allocated through the SLUB fastpath. | ||
128 | * | ||
129 | * This should be dropped to PAGE_SIZE / 2 once the page allocator | ||
130 | * "fastpath" becomes competitive with the slab allocator fastpaths. | ||
131 | */ | ||
132 | #define SLUB_MAX_SIZE (PAGE_SIZE) | ||
133 | |||
134 | #define SLUB_PAGE_SHIFT (PAGE_SHIFT + 1) | ||
135 | |||
136 | /* | ||
124 | * We keep the general caches in an array of slab caches that are used for | 137 | * We keep the general caches in an array of slab caches that are used for |
125 | * 2^x bytes of allocations. | 138 | * 2^x bytes of allocations. |
126 | */ | 139 | */ |
127 | extern struct kmem_cache kmalloc_caches[PAGE_SHIFT + 1]; | 140 | extern struct kmem_cache kmalloc_caches[SLUB_PAGE_SHIFT]; |
128 | 141 | ||
129 | /* | 142 | /* |
130 | * Sorry that the following has to be that ugly but some versions of GCC | 143 | * Sorry that the following has to be that ugly but some versions of GCC |
@@ -212,7 +225,7 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags) | |||
212 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | 225 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
213 | { | 226 | { |
214 | if (__builtin_constant_p(size)) { | 227 | if (__builtin_constant_p(size)) { |
215 | if (size > PAGE_SIZE) | 228 | if (size > SLUB_MAX_SIZE) |
216 | return kmalloc_large(size, flags); | 229 | return kmalloc_large(size, flags); |
217 | 230 | ||
218 | if (!(flags & SLUB_DMA)) { | 231 | if (!(flags & SLUB_DMA)) { |
@@ -234,7 +247,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); | |||
234 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) | 247 | static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) |
235 | { | 248 | { |
236 | if (__builtin_constant_p(size) && | 249 | if (__builtin_constant_p(size) && |
237 | size <= PAGE_SIZE && !(flags & SLUB_DMA)) { | 250 | size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) { |
238 | struct kmem_cache *s = kmalloc_slab(size); | 251 | struct kmem_cache *s = kmalloc_slab(size); |
239 | 252 | ||
240 | if (!s) | 253 | if (!s) |
@@ -2475,7 +2475,7 @@ EXPORT_SYMBOL(kmem_cache_destroy); | |||
2475 | * Kmalloc subsystem | 2475 | * Kmalloc subsystem |
2476 | *******************************************************************/ | 2476 | *******************************************************************/ |
2477 | 2477 | ||
2478 | struct kmem_cache kmalloc_caches[PAGE_SHIFT + 1] __cacheline_aligned; | 2478 | struct kmem_cache kmalloc_caches[SLUB_PAGE_SHIFT] __cacheline_aligned; |
2479 | EXPORT_SYMBOL(kmalloc_caches); | 2479 | EXPORT_SYMBOL(kmalloc_caches); |
2480 | 2480 | ||
2481 | static int __init setup_slub_min_order(char *str) | 2481 | static int __init setup_slub_min_order(char *str) |
@@ -2537,7 +2537,7 @@ panic: | |||
2537 | } | 2537 | } |
2538 | 2538 | ||
2539 | #ifdef CONFIG_ZONE_DMA | 2539 | #ifdef CONFIG_ZONE_DMA |
2540 | static struct kmem_cache *kmalloc_caches_dma[PAGE_SHIFT + 1]; | 2540 | static struct kmem_cache *kmalloc_caches_dma[SLUB_PAGE_SHIFT]; |
2541 | 2541 | ||
2542 | static void sysfs_add_func(struct work_struct *w) | 2542 | static void sysfs_add_func(struct work_struct *w) |
2543 | { | 2543 | { |
@@ -2658,7 +2658,7 @@ void *__kmalloc(size_t size, gfp_t flags) | |||
2658 | { | 2658 | { |
2659 | struct kmem_cache *s; | 2659 | struct kmem_cache *s; |
2660 | 2660 | ||
2661 | if (unlikely(size > PAGE_SIZE)) | 2661 | if (unlikely(size > SLUB_MAX_SIZE)) |
2662 | return kmalloc_large(size, flags); | 2662 | return kmalloc_large(size, flags); |
2663 | 2663 | ||
2664 | s = get_slab(size, flags); | 2664 | s = get_slab(size, flags); |
@@ -2686,7 +2686,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) | |||
2686 | { | 2686 | { |
2687 | struct kmem_cache *s; | 2687 | struct kmem_cache *s; |
2688 | 2688 | ||
2689 | if (unlikely(size > PAGE_SIZE)) | 2689 | if (unlikely(size > SLUB_MAX_SIZE)) |
2690 | return kmalloc_large_node(size, flags, node); | 2690 | return kmalloc_large_node(size, flags, node); |
2691 | 2691 | ||
2692 | s = get_slab(size, flags); | 2692 | s = get_slab(size, flags); |
@@ -2985,7 +2985,7 @@ void __init kmem_cache_init(void) | |||
2985 | caches++; | 2985 | caches++; |
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | for (i = KMALLOC_SHIFT_LOW; i <= PAGE_SHIFT; i++) { | 2988 | for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) { |
2989 | create_kmalloc_cache(&kmalloc_caches[i], | 2989 | create_kmalloc_cache(&kmalloc_caches[i], |
2990 | "kmalloc", 1 << i, GFP_KERNEL); | 2990 | "kmalloc", 1 << i, GFP_KERNEL); |
2991 | caches++; | 2991 | caches++; |
@@ -3022,7 +3022,7 @@ void __init kmem_cache_init(void) | |||
3022 | slab_state = UP; | 3022 | slab_state = UP; |
3023 | 3023 | ||
3024 | /* Provide the correct kmalloc names now that the caches are up */ | 3024 | /* Provide the correct kmalloc names now that the caches are up */ |
3025 | for (i = KMALLOC_SHIFT_LOW; i <= PAGE_SHIFT; i++) | 3025 | for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) |
3026 | kmalloc_caches[i]. name = | 3026 | kmalloc_caches[i]. name = |
3027 | kasprintf(GFP_KERNEL, "kmalloc-%d", 1 << i); | 3027 | kasprintf(GFP_KERNEL, "kmalloc-%d", 1 << i); |
3028 | 3028 | ||
@@ -3222,7 +3222,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller) | |||
3222 | { | 3222 | { |
3223 | struct kmem_cache *s; | 3223 | struct kmem_cache *s; |
3224 | 3224 | ||
3225 | if (unlikely(size > PAGE_SIZE)) | 3225 | if (unlikely(size > SLUB_MAX_SIZE)) |
3226 | return kmalloc_large(size, gfpflags); | 3226 | return kmalloc_large(size, gfpflags); |
3227 | 3227 | ||
3228 | s = get_slab(size, gfpflags); | 3228 | s = get_slab(size, gfpflags); |
@@ -3238,7 +3238,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | |||
3238 | { | 3238 | { |
3239 | struct kmem_cache *s; | 3239 | struct kmem_cache *s; |
3240 | 3240 | ||
3241 | if (unlikely(size > PAGE_SIZE)) | 3241 | if (unlikely(size > SLUB_MAX_SIZE)) |
3242 | return kmalloc_large_node(size, gfpflags, node); | 3242 | return kmalloc_large_node(size, gfpflags, node); |
3243 | 3243 | ||
3244 | s = get_slab(size, gfpflags); | 3244 | s = get_slab(size, gfpflags); |