Re: [PATCH 4/5] cpuset memory spread slab cache optimizations

From: Andrew Morton
Date: Sat Feb 04 2006 - 18:50:41 EST


Paul Jackson <pj@xxxxxxx> wrote:
>
> @@ -2703,20 +2704,9 @@ static inline void *____cache_alloc(stru
> struct array_cache *ac;
>
> #ifdef CONFIG_NUMA
> - if (unlikely(current->mempolicy && !in_interrupt())) {
> - int nid = slab_node(current->mempolicy);
> -
> - if (nid != numa_node_id())
> - return __cache_alloc_node(cachep, flags, nid);
> - }
> - if (unlikely(cpuset_mem_spread_check() &&
> - (cachep->flags & SLAB_MEM_SPREAD) &&
> - !in_interrupt())) {
> - int nid = cpuset_mem_spread_node();
> -
> - if (nid != numa_node_id())
> - return __cache_alloc_node(cachep, flags, nid);
> - }
> + if (unlikely(current->flags & (PF_MEM_SPREAD|PF_MEMPOLICY)))
> + if ((objp = alternate_node_alloc(cachep, flags)) != NULL)
> + return objp;
> #endif
>
> check_irq_off();
> @@ -2751,6 +2741,25 @@ __cache_alloc(struct kmem_cache *cachep,
>
> #ifdef CONFIG_NUMA
> /*
> + * Try allocating on another node if PF_MEM_SPREAD or PF_MEMPOLICY.
> + */
> +static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
> +{
> + int nid_alloc, nid_here;
> +
> + if (in_interrupt())
> + return NULL;
> + nid_alloc = nid_here = numa_node_id();
> + if (cpuset_mem_spread_check() && (cachep->flags & SLAB_MEM_SPREAD))
> + nid_alloc = cpuset_mem_spread_node();
> + else if (current->mempolicy)
> + nid_alloc = slab_node(current->mempolicy);
> + if (nid_alloc != nid_here)
> + return __cache_alloc_node(cachep, flags, nid_alloc);
> + return NULL;
> +}
> +

Why not move the PF_MEM_SPREAD|PF_MEMPOLICY test into
alternate_node_alloc(), inline the whole thing and nuke the #ifdef in
__cache_alloc()?

We're adding even more goop into the NUMA __cache_alloc() fastpath. This bad.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/