From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: linux-kernel@vger.kernel.org,
David Rientjes <rientjes@google.com>,
Andi Kleen <andi@firstfloor.org>
Subject: [RFC] slub: Per object NUMA support
Date: Fri, 15 Apr 2011 14:56:14 -0500 (CDT) [thread overview]
Message-ID: <alpine.DEB.2.00.1104151449370.12627@router.home> (raw)
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
next reply other threads:[~2011-04-15 19:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 19:56 Christoph Lameter [this message]
2011-05-11 21:13 ` David Rientjes
2011-05-12 14:46 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1104151449370.12627@router.home \
--to=cl@linux.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®