Re: [PATCH] slub: Don't throw away partial remote slabs if there is no local memory

David Rientjes
2014-01-24T23:49:46Z

On Fri, 24 Jan 2014, Nishanth Aravamudan wrote:

> > I think the problem is a memoryless node being used for kmalloc_node() so
> > we need to decide where to enforce node_present_pages(). __slab_alloc()
> > seems like the best candidate when !node_match().
>
> Actually, this is effectively what Anton's patch does, except with
> Wanpeng's adjustment to use node_present_pages(). Does that seem
> sufficient to you?
>

I don't see that as being the effect of Anton's patch. We need to use
numa_mem_id() as Christoph mentioned when a memoryless node is passed for
the best NUMA locality. Something like this:

diff --git a/mm/slub.c b/mm/slub.c
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2278,10 +2278,14 @@ redo:

if (unlikely(!node_match(page, node))) {
stat(s, ALLOC_NODE_MISMATCH);
- deactivate_slab(s, page, c->freelist);
- c->page = NULL;
- c->freelist = NULL;
- goto new_slab;
+ if (unlikely(!node_present_pages(node)))
+ node = numa_mem_id();
+ if (!node_match(page, node)) {
+ deactivate_slab(s, page, c->freelist);
+ c->page = NULL;
+ c->freelist = NULL;
+ goto new_slab;
+ }
}

/*

> It does only cover the memoryless node case (not the exhausted node
> case), but I think that shouldn't block the fix (and it does fix the
> issue we've run across in our testing).
>

kmalloc_node(nid) and kmem_cache_alloc_node(nid) should fallback to nodes
other than nid when memory can't be allocated, these functions only
indicate a preference.