aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/slab.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/mm/slab.c b/mm/slab.c
index bfd654c0ef41..8f3f61cacb5c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1015,7 +1015,7 @@ static inline void *alternate_node_alloc(struct kmem_cache *cachep,
1015 return NULL; 1015 return NULL;
1016} 1016}
1017 1017
1018static inline void *__cache_alloc_node(struct kmem_cache *cachep, 1018static inline void *____cache_alloc_node(struct kmem_cache *cachep,
1019 gfp_t flags, int nodeid) 1019 gfp_t flags, int nodeid)
1020{ 1020{
1021 return NULL; 1021 return NULL;
@@ -1023,7 +1023,7 @@ static inline void *__cache_alloc_node(struct kmem_cache *cachep,
1023 1023
1024#else /* CONFIG_NUMA */ 1024#else /* CONFIG_NUMA */
1025 1025
1026static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int); 1026static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
1027static void *alternate_node_alloc(struct kmem_cache *, gfp_t); 1027static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
1028 1028
1029static struct array_cache **alloc_alien_cache(int node, int limit) 1029static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -3130,10 +3130,10 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
3130 objp = ____cache_alloc(cachep, flags); 3130 objp = ____cache_alloc(cachep, flags);
3131 /* 3131 /*
3132 * We may just have run out of memory on the local node. 3132 * We may just have run out of memory on the local node.
3133 * __cache_alloc_node() knows how to locate memory on other nodes 3133 * ____cache_alloc_node() knows how to locate memory on other nodes
3134 */ 3134 */
3135 if (NUMA_BUILD && !objp) 3135 if (NUMA_BUILD && !objp)
3136 objp = __cache_alloc_node(cachep, flags, numa_node_id()); 3136 objp = ____cache_alloc_node(cachep, flags, numa_node_id());
3137 local_irq_restore(save_flags); 3137 local_irq_restore(save_flags);
3138 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 3138 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
3139 caller); 3139 caller);
@@ -3160,7 +3160,7 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3160 else if (current->mempolicy) 3160 else if (current->mempolicy)
3161 nid_alloc = slab_node(current->mempolicy); 3161 nid_alloc = slab_node(current->mempolicy);
3162 if (nid_alloc != nid_here) 3162 if (nid_alloc != nid_here)
3163 return __cache_alloc_node(cachep, flags, nid_alloc); 3163 return ____cache_alloc_node(cachep, flags, nid_alloc);
3164 return NULL; 3164 return NULL;
3165} 3165}
3166 3166
@@ -3183,7 +3183,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3183 if (zone_idx(*z) <= ZONE_NORMAL && 3183 if (zone_idx(*z) <= ZONE_NORMAL &&
3184 cpuset_zone_allowed(*z, flags) && 3184 cpuset_zone_allowed(*z, flags) &&
3185 cache->nodelists[nid]) 3185 cache->nodelists[nid])
3186 obj = __cache_alloc_node(cache, 3186 obj = ____cache_alloc_node(cache,
3187 flags | __GFP_THISNODE, nid); 3187 flags | __GFP_THISNODE, nid);
3188 } 3188 }
3189 return obj; 3189 return obj;
@@ -3192,7 +3192,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3192/* 3192/*
3193 * A interface to enable slab creation on nodeid 3193 * A interface to enable slab creation on nodeid
3194 */ 3194 */
3195static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, 3195static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3196 int nodeid) 3196 int nodeid)
3197{ 3197{
3198 struct list_head *entry; 3198 struct list_head *entry;
@@ -3465,7 +3465,9 @@ out:
3465 * New and improved: it will now make sure that the object gets 3465 * New and improved: it will now make sure that the object gets
3466 * put on the correct node list so that there is no false sharing. 3466 * put on the correct node list so that there is no false sharing.
3467 */ 3467 */
3468void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) 3468static __always_inline void *
3469__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3470 int nodeid, void *caller)
3469{ 3471{
3470 unsigned long save_flags; 3472 unsigned long save_flags;
3471 void *ptr; 3473 void *ptr;
@@ -3477,17 +3479,23 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3477 !cachep->nodelists[nodeid]) 3479 !cachep->nodelists[nodeid])
3478 ptr = ____cache_alloc(cachep, flags); 3480 ptr = ____cache_alloc(cachep, flags);
3479 else 3481 else
3480 ptr = __cache_alloc_node(cachep, flags, nodeid); 3482 ptr = ____cache_alloc_node(cachep, flags, nodeid);
3481 local_irq_restore(save_flags); 3483 local_irq_restore(save_flags);
3482 3484
3483 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, 3485 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
3484 __builtin_return_address(0));
3485 3486
3486 return ptr; 3487 return ptr;
3487} 3488}
3489
3490void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3491{
3492 return __cache_alloc_node(cachep, flags, nodeid,
3493 __builtin_return_address(0));
3494}
3488EXPORT_SYMBOL(kmem_cache_alloc_node); 3495EXPORT_SYMBOL(kmem_cache_alloc_node);
3489 3496
3490void *__kmalloc_node(size_t size, gfp_t flags, int node) 3497static __always_inline void *
3498__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
3491{ 3499{
3492 struct kmem_cache *cachep; 3500 struct kmem_cache *cachep;
3493 3501
@@ -3496,8 +3504,29 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
3496 return NULL; 3504 return NULL;
3497 return kmem_cache_alloc_node(cachep, flags, node); 3505 return kmem_cache_alloc_node(cachep, flags, node);
3498} 3506}
3507
3508#ifdef CONFIG_DEBUG_SLAB
3509void *__kmalloc_node(size_t size, gfp_t flags, int node)
3510{
3511 return __do_kmalloc_node(size, flags, node,
3512 __builtin_return_address(0));
3513}
3499EXPORT_SYMBOL(__kmalloc_node); 3514EXPORT_SYMBOL(__kmalloc_node);
3500#endif 3515
3516void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
3517 int node, void *caller)
3518{
3519 return __do_kmalloc_node(size, flags, node, caller);
3520}
3521EXPORT_SYMBOL(__kmalloc_node_track_caller);
3522#else
3523void *__kmalloc_node(size_t size, gfp_t flags, int node)
3524{
3525 return __do_kmalloc_node(size, flags, node, NULL);
3526}
3527EXPORT_SYMBOL(__kmalloc_node);
3528#endif /* CONFIG_DEBUG_SLAB */
3529#endif /* CONFIG_NUMA */
3501 3530
3502/** 3531/**
3503 * __do_kmalloc - allocate memory 3532 * __do_kmalloc - allocate memory