Re: [PATCH] Fix boot problem in situations where the boot CPU is running on a memoryless node

Pekka J Enberg
2008-01-23T14:32:40Z

On Wed, 23 Jan 2008, Pekka J Enberg wrote:
> I still think Christoph's kmem_getpages() patch is correct (to fix
> cache_grow() oops) but I overlooked the fact that none the callers of
> ____cache_alloc_node() deal with bootstrapping (with the exception of
> __cache_alloc_node() that even has a comment about it).

So something like this (totally untested) patch on top of current git:

---
mm/slab.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c
+++ linux-2.6/mm/slab.c
@@ -1668,7 +1668,11 @@ static void *kmem_getpages(struct kmem_c
if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
flags |= __GFP_RECLAIMABLE;

- page = alloc_pages_node(nodeid, flags, cachep->gfporder);
+ if (nodeid == -1)
+ page = alloc_pages(flags, cachep->gfporder);
+ else
+ page = alloc_pages_node(nodeid, flags, cachep->gfporder);
+
if (!page)
return NULL;

@@ -2976,8 +2980,9 @@ retry:
batchcount = BATCHREFILL_LIMIT;
}
l3 = cachep->nodelists[node];
+ if (!l3)
+ return NULL;

- BUG_ON(ac->avail > 0 || !l3);
spin_lock(&l3->list_lock);

/* See if we can refill from the shared array */
@@ -3317,7 +3322,8 @@ static void *____cache_alloc_node(struct
int x;

l3 = cachep->nodelists[nodeid];
- BUG_ON(!l3);
+ if (!l3)
+ return fallback_alloc(cachep, flags);

retry:
check_irq_off();
@@ -3394,12 +3400,6 @@ __cache_alloc_node(struct kmem_cache *ca
if (unlikely(nodeid == -1))
nodeid = numa_node_id();

- if (unlikely(!cachep->nodelists[nodeid])) {
- /* Node not bootstrapped yet */
- ptr = fallback_alloc(cachep, flags);
- goto out;
- }
-
if (nodeid == numa_node_id()) {
/*
* Use the locally cached objects if possible.