diff options
-rw-r--r-- | include/linux/slub_def.h | 8 | ||||
-rw-r--r-- | mm/slub.c | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 5e6d3d634d5b..a849c472b845 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -188,12 +188,16 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size) | |||
188 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); | 188 | void *kmem_cache_alloc(struct kmem_cache *, gfp_t); |
189 | void *__kmalloc(size_t size, gfp_t flags); | 189 | void *__kmalloc(size_t size, gfp_t flags); |
190 | 190 | ||
191 | static __always_inline void *kmalloc_large(size_t size, gfp_t flags) | ||
192 | { | ||
193 | return (void *)__get_free_pages(flags | __GFP_COMP, get_order(size)); | ||
194 | } | ||
195 | |||
191 | static __always_inline void *kmalloc(size_t size, gfp_t flags) | 196 | static __always_inline void *kmalloc(size_t size, gfp_t flags) |
192 | { | 197 | { |
193 | if (__builtin_constant_p(size)) { | 198 | if (__builtin_constant_p(size)) { |
194 | if (size > PAGE_SIZE / 2) | 199 | if (size > PAGE_SIZE / 2) |
195 | return (void *)__get_free_pages(flags | __GFP_COMP, | 200 | return kmalloc_large(size, flags); |
196 | get_order(size)); | ||
197 | 201 | ||
198 | if (!(flags & SLUB_DMA)) { | 202 | if (!(flags & SLUB_DMA)) { |
199 | struct kmem_cache *s = kmalloc_slab(size); | 203 | struct kmem_cache *s = kmalloc_slab(size); |
@@ -2671,8 +2671,7 @@ void *__kmalloc(size_t size, gfp_t flags) | |||
2671 | struct kmem_cache *s; | 2671 | struct kmem_cache *s; |
2672 | 2672 | ||
2673 | if (unlikely(size > PAGE_SIZE / 2)) | 2673 | if (unlikely(size > PAGE_SIZE / 2)) |
2674 | return (void *)__get_free_pages(flags | __GFP_COMP, | 2674 | return kmalloc_large(size, flags); |
2675 | get_order(size)); | ||
2676 | 2675 | ||
2677 | s = get_slab(size, flags); | 2676 | s = get_slab(size, flags); |
2678 | 2677 | ||
@@ -2689,8 +2688,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) | |||
2689 | struct kmem_cache *s; | 2688 | struct kmem_cache *s; |
2690 | 2689 | ||
2691 | if (unlikely(size > PAGE_SIZE / 2)) | 2690 | if (unlikely(size > PAGE_SIZE / 2)) |
2692 | return (void *)__get_free_pages(flags | __GFP_COMP, | 2691 | return kmalloc_large(size, flags); |
2693 | get_order(size)); | ||
2694 | 2692 | ||
2695 | s = get_slab(size, flags); | 2693 | s = get_slab(size, flags); |
2696 | 2694 | ||
@@ -3219,8 +3217,8 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, void *caller) | |||
3219 | struct kmem_cache *s; | 3217 | struct kmem_cache *s; |
3220 | 3218 | ||
3221 | if (unlikely(size > PAGE_SIZE / 2)) | 3219 | if (unlikely(size > PAGE_SIZE / 2)) |
3222 | return (void *)__get_free_pages(gfpflags | __GFP_COMP, | 3220 | return kmalloc_large(size, gfpflags); |
3223 | get_order(size)); | 3221 | |
3224 | s = get_slab(size, gfpflags); | 3222 | s = get_slab(size, gfpflags); |
3225 | 3223 | ||
3226 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3224 | if (unlikely(ZERO_OR_NULL_PTR(s))) |
@@ -3235,8 +3233,8 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags, | |||
3235 | struct kmem_cache *s; | 3233 | struct kmem_cache *s; |
3236 | 3234 | ||
3237 | if (unlikely(size > PAGE_SIZE / 2)) | 3235 | if (unlikely(size > PAGE_SIZE / 2)) |
3238 | return (void *)__get_free_pages(gfpflags | __GFP_COMP, | 3236 | return kmalloc_large(size, gfpflags); |
3239 | get_order(size)); | 3237 | |
3240 | s = get_slab(size, gfpflags); | 3238 | s = get_slab(size, gfpflags); |
3241 | 3239 | ||
3242 | if (unlikely(ZERO_OR_NULL_PTR(s))) | 3240 | if (unlikely(ZERO_OR_NULL_PTR(s))) |