Re: [PATCH] online CPU before memory failed in pcpu_alloc_pages()

From: minskey guo
Date: Fri May 21 2010 - 04:22:54 EST

--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -714,13 +714,29 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk,

In linux-next, Tejun has gone and moved pcpu_alloc_pages() into the new
mm/percpu-vm.c. So either

This has gone into Linus' tree today ...

Hmm, a comment here.

Recently, Lee Schermerhorn developed


Then, you can use cpu_to_mem() instead of cpu_to_node() to find the
nearest available node.
I don't check cpu_to_mem() is synchronized with NUMA hotplug but
using cpu_to_mem() rather than adding

+ if ((nid == -1) ||
+ !(node_zonelist(nid, GFP_KERNEL)->_zonerefs->zone))
+ nid = numa_node_id();

is better.

Yes. I can use cpu_to_mem(). only some little difference during
CPU online: 1st cpu within memoryless node gets memory from current
node or the node to which the cpu0 belongs,

But I have a question about the patch:


@@ -2968,9 +2991,23 @@ static int __build_all_zonelists(void *d

- for_each_possible_cpu(cpu)
+ for_each_possible_cpu(cpu) {
setup_pageset(&per_cpu(boot_pageset, cpu), 0);

+ if (cpu_online(cpu))
+ cpu_to_mem(cpu) = local_memory_node(cpu_to_node(cpu));

Look at the last two lines, suppose that memory is onlined before CPUs,
where will cpu_to_mem(cpu) be set to the right nodeid for the last
onlined cpu ? Does that CPU always get memory from the node including cpu0 for slab allocator where cpu_to_mem() is used ?


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at