Fix kmalloc_node applying memory policies if nodeid == numa_node_id() kmalloc_node falls back to ___cache_alloc() under certain conditions and at that point memory policies may be applied redirecting the allocation away from the current node. Fix this by doing the policy check in __cache_alloc instead of ____cache_alloc. Signed-off-by: Christoph Lameter Index: linux-2.6.18-rc6-mm2/mm/slab.c =================================================================== --- linux-2.6.18-rc6-mm2.orig/mm/slab.c 2006-09-13 17:45:36.000000000 -0500 +++ linux-2.6.18-rc6-mm2/mm/slab.c 2006-09-13 18:04:57.889185988 -0500 @@ -3052,14 +3052,6 @@ void *objp; struct array_cache *ac; -#ifdef CONFIG_NUMA - if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) { - objp = alternate_node_alloc(cachep, flags); - if (objp != NULL) - return objp; - } -#endif - check_irq_off(); ac = cpu_cache_get(cachep); if (likely(ac->avail)) { @@ -3082,7 +3074,17 @@ cache_alloc_debugcheck_before(cachep, flags); local_irq_save(save_flags); + +#ifdef CONFIG_NUMA + if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) { + objp = alternate_node_alloc(cachep, flags); + if (objp != NULL) + goto out; + } +#endif + objp = ____cache_alloc(cachep, flags); +out: local_irq_restore(save_flags); objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);