* [RFC] slub: Per object NUMA support
@ 2011-04-15 19:56 Christoph Lameter
2011-05-11 21:13 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Lameter @ 2011-04-15 19:56 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-kernel, David Rientjes, Andi Kleen
I am not sure if such a feature is needed/wanted/desired. It would make
the object allocation method similar to SLAB instead of relying on page
based policy application (which IMHO was the intend of the memory policy
system before Paul Jackson got that changed in SLAB).
Anyways the implementation is rather simple.
Currently slub applies NUMA policies per allocated slab page. Change
that to apply memory policies for each individual object allocated.
F.e. before this patch MPOL_INTERLEAVE would return objects from the
same slab page until a new slab page was allocated. Now an object
from a different page is taken for each allocation.
This increases the overhead of the fastpath under NUMA.
Signed-off-by: Christoph Lameter <cl@linux.com>
---
mm/slub.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2011-04-15 12:54:42.000000000 -0500
+++ linux-2.6/mm/slub.c 2011-04-15 13:11:25.000000000 -0500
@@ -1887,6 +1887,21 @@ debug:
goto unlock_out;
}
+static __always_inline int alternate_slab_node(struct kmem_cache *s,
+ gfp_t flags, int node)
+{
+#ifdef CONFIG_NUMA
+ if (unlikely(node == NUMA_NO_NODE &&
+ !(flags & __GFP_THISNODE) &&
+ !in_interrupt())) {
+ if ((s->flags & SLAB_MEM_SPREAD) && cpuset_do_slab_mem_spread())
+ node = cpuset_slab_spread_node();
+ else if (current->mempolicy)
+ node = slab_node(current->mempolicy);
+ }
+#endif
+ return node;
+}
/*
* Inlined fastpath so that allocation functions (kmalloc, kmem_cache_alloc)
* have the fastpath folded into their functions. So no function call
@@ -1911,6 +1926,7 @@ static __always_inline void *slab_alloc(
if (slab_pre_alloc_hook(s, gfpflags))
return NULL;
+ node = alternate_slab_node(s, gfpflags, node);
#ifndef CONFIG_CMPXCHG_LOCAL
local_irq_save(flags);
#else
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] slub: Per object NUMA support
2011-04-15 19:56 [RFC] slub: Per object NUMA support Christoph Lameter
@ 2011-05-11 21:13 ` David Rientjes
2011-05-12 14:46 ` Christoph Lameter
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2011-05-11 21:13 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, linux-kernel, Andi Kleen
On Fri, 15 Apr 2011, Christoph Lameter wrote:
> I am not sure if such a feature is needed/wanted/desired. It would make
> the object allocation method similar to SLAB instead of relying on page
> based policy application (which IMHO was the intend of the memory policy
> system before Paul Jackson got that changed in SLAB).
>
> Anyways the implementation is rather simple.
>
The implementation may be simple, but it seems like this would absolutely
kill performance for MPOL_INTERLEAVE if slub is required for every
kmalloc() or kmem_cache_alloc() to take the alternate slab node's
list_lock to scan the partial list or, worse yet, allocate a new slab on
that node when there are objects available on the freelist.
That, to me, would always nullify the performance benefit of using the
mempolicy in the first place and end up making MPOL_INTERLEAVE worse than
no mempolicy. Do you have any benchmarks that suggest this has no
negative impact? I'd be very surprised.
> Currently slub applies NUMA policies per allocated slab page. Change
> that to apply memory policies for each individual object allocated.
>
> F.e. before this patch MPOL_INTERLEAVE would return objects from the
> same slab page until a new slab page was allocated. Now an object
> from a different page is taken for each allocation.
>
> This increases the overhead of the fastpath under NUMA.
>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> ---
> mm/slub.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> Index: linux-2.6/mm/slub.c
> ===================================================================
> --- linux-2.6.orig/mm/slub.c 2011-04-15 12:54:42.000000000 -0500
> +++ linux-2.6/mm/slub.c 2011-04-15 13:11:25.000000000 -0500
> @@ -1887,6 +1887,21 @@ debug:
> goto unlock_out;
> }
>
> +static __always_inline int alternate_slab_node(struct kmem_cache *s,
> + gfp_t flags, int node)
> +{
> +#ifdef CONFIG_NUMA
> + if (unlikely(node == NUMA_NO_NODE &&
> + !(flags & __GFP_THISNODE) &&
> + !in_interrupt())) {
> + if ((s->flags & SLAB_MEM_SPREAD) && cpuset_do_slab_mem_spread())
> + node = cpuset_slab_spread_node();
> + else if (current->mempolicy)
> + node = slab_node(current->mempolicy);
> + }
> +#endif
> + return node;
> +}
> /*
> * Inlined fastpath so that allocation functions (kmalloc, kmem_cache_alloc)
> * have the fastpath folded into their functions. So no function call
> @@ -1911,6 +1926,7 @@ static __always_inline void *slab_alloc(
> if (slab_pre_alloc_hook(s, gfpflags))
> return NULL;
>
> + node = alternate_slab_node(s, gfpflags, node);
> #ifndef CONFIG_CMPXCHG_LOCAL
> local_irq_save(flags);
> #else
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] slub: Per object NUMA support
2011-05-11 21:13 ` David Rientjes
@ 2011-05-12 14:46 ` Christoph Lameter
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Lameter @ 2011-05-12 14:46 UTC (permalink / raw)
To: David Rientjes; +Cc: Pekka Enberg, linux-kernel, Andi Kleen
On Wed, 11 May 2011, David Rientjes wrote:
> > Anyways the implementation is rather simple.
> >
>
> The implementation may be simple, but it seems like this would absolutely
> kill performance for MPOL_INTERLEAVE if slub is required for every
> kmalloc() or kmem_cache_alloc() to take the alternate slab node's
> list_lock to scan the partial list or, worse yet, allocate a new slab on
> that node when there are objects available on the freelist.
Right. SLAB does something similar though. We could optimize it more by
taking locks like done there and aovid the switching of the per cpu slabs.
> That, to me, would always nullify the performance benefit of using the
> mempolicy in the first place and end up making MPOL_INTERLEAVE worse than
> no mempolicy. Do you have any benchmarks that suggest this has no
> negative impact? I'd be very surprised.
The default is no memory policy. You would only use MPOL_INTERLEAVE on
large NUMA system that incur sufficient cross node latency to justify the
interleave.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-12 14:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-15 19:56 [RFC] slub: Per object NUMA support Christoph Lameter
2011-05-11 21:13 ` David Rientjes
2011-05-12 14:46 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®