Re: [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu to node



On Tue, 26 Sep 2006 19:23:05 +0800
"bibo,mao" <bibo.mao@xxxxxxxxx> wrote:

KAMEZAWA Hiroyuki wrote:
Assume that a cpu is *physically* offlined at boot time...

Because smpboot.c::smp_boot_cpu_map() canoot find cpu's sapicid,
numa.c::build_cpu_to_node_map() cannot build cpu<->node map for
offlined cpu.

For such cpus, cpu_to_node map should be fixed at cpu-hot-add.
This mapping should be done before cpu onlining.

This patch also handles cpu hotremove case.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>


arch/ia64/kernel/numa.c | 34 +++++++++++++++++++++++++++++++---
arch/ia64/kernel/topology.c | 6 +++++-
include/asm-ia64/numa.h | 4 ++++
3 files changed, 40 insertions(+), 4 deletions(-)

Index: linux-2.6.18/arch/ia64/kernel/numa.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/numa.c 2006-09-22 14:22:44.000000000 +0900
+++ linux-2.6.18/arch/ia64/kernel/numa.c 2006-09-22 14:44:46.000000000 +0900
@@ -29,6 +29,36 @@

cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;

+void __cpuinit map_cpu_to_node(int cpu, int nid)
+{
+ int oldnid;
+ if (nid < 0) { /* just initialize by zero */
+ cpu_to_node_map[cpu] = 0;
+ return;
+ }
+ /* sanity check first */
+ oldnid = cpu_to_node_map[cpu];
+ if (cpu_isset(cpu, node_to_cpu_mask[oldnid])) {
+ return; /* nothing to do */
+ }
+ /* we don't have cpu-driven node hot add yet...
+ In usual case, node is created from SRAT at boot time. */
+ if (!node_online(nid))
+ nid = first_online_node;
+ cpu_to_node_map[cpu] = nid;
+ cpu_set(cpu, node_to_cpu_mask[nid]);
+ return;
+}
+
+void __cpuinit unmap_cpu_from_node(int cpu, int nid)
+{
+ WARN_ON(!cpu_isset(cpu, node_to_cpu_mask[nid]));
+ WARN_ON(cpu_to_node_map[cpu] != nid);
+ cpu_to_node_map[cpu] = 0;
+ cpu_clear(cpu, node_to_cpu_mask[nid]);
+}
+
+
/**
* build_cpu_to_node_map - setup cpu to node and node to cpumask arrays
*
@@ -49,8 +79,6 @@
node = node_cpuid[i].nid;
break;
}
- cpu_to_node_map[cpu] = (node >= 0) ? node : 0;
- if (node >= 0)
- cpu_set(cpu, node_to_cpu_mask[node]);
+ map_cpu_to_node(cpu, node);
}
}
Index: linux-2.6.18/include/asm-ia64/numa.h
===================================================================
--- linux-2.6.18.orig/include/asm-ia64/numa.h 2006-09-22 14:22:44.000000000 +0900
+++ linux-2.6.18/include/asm-ia64/numa.h 2006-09-22 14:25:07.000000000 +0900
@@ -64,6 +64,10 @@

#define local_nodeid (cpu_to_node_map[smp_processor_id()])

+extern void map_cpu_to_node(int cpu, int nid);
+extern void unmap_cpu_from_node(int cpu, int nid);
+
+
#else /* !CONFIG_NUMA */

#define paddr_to_nid(addr) 0
Index: linux-2.6.18/arch/ia64/kernel/topology.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/topology.c 2006-09-22 14:22:44.000000000 +0900
+++ linux-2.6.18/arch/ia64/kernel/topology.c 2006-09-22 14:25:07.000000000 +0900
@@ -36,6 +36,9 @@
*/
if (!can_cpei_retarget() && is_cpu_cpei_target(num))
sysfs_cpus[num].cpu.no_control = 1;
+#ifdef CONFIG_NUMA
+ map_cpu_to_node(num, node_cpuid[num].nid);
+#endif
#endif

return register_cpu(&sysfs_cpus[num].cpu, num);
@@ -45,7 +48,8 @@

void arch_unregister_cpu(int num)
{
- return unregister_cpu(&sysfs_cpus[num].cpu);
+ unregister_cpu(&sysfs_cpus[num].cpu);
+ unmap_cpu_from_node(num, cpu_to_node(num));
This patch failed to compile in my IA64 box, my machine is not NUMA machine,
there is unmap_cpu_from_node not defined error like this.

arch/ia64/kernel/built-in.o: In function `arch_unregister_cpu':
arch/ia64/kernel/topology.c:52: undefined reference to `unmap_cpu_from_node'
make: *** [.tmp_vmlinux1] Error 1

thanks
bibo,mao


Uh... sorry. How about this hot-fix ?

-Kame
=========


Non-NUMA case should be handled...

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

Index: linux-2.6.18/arch/ia64/kernel/topology.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/topology.c 2006-09-26 20:31:25.000000000 +0900
+++ linux-2.6.18/arch/ia64/kernel/topology.c 2006-09-26 20:34:03.000000000 +0900
@@ -36,10 +36,8 @@
*/
if (!can_cpei_retarget() && is_cpu_cpei_target(num))
sysfs_cpus[num].cpu.no_control = 1;
-#ifdef CONFIG_NUMA
map_cpu_to_node(num, node_cpuid[num].nid);
#endif
-#endif

return register_cpu(&sysfs_cpus[num].cpu, num);
}
Index: linux-2.6.18/include/asm-ia64/numa.h
===================================================================
--- linux-2.6.18.orig/include/asm-ia64/numa.h 2006-09-26 20:31:25.000000000 +0900
+++ linux-2.6.18/include/asm-ia64/numa.h 2006-09-26 20:33:49.000000000 +0900
@@ -69,6 +69,8 @@


#else /* !CONFIG_NUMA */
+#define map_cpu_to_node(cpu, nid) do{}while(0)
+#define unmap_cpu_from_node(cpu, nid) do{}while(0)

#define paddr_to_nid(addr) 0






-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: x86/non-x86: percpu, node ids, apic ids x86.git fixup
    ... This patch is from a different patch set. ... Subject: generic: percpu infrastructure to rebase the per cpu area to zero ... static void sun4u_pgprot_init; ...
    (Linux-Kernel)
  • take3: Updated CPU Hotplug patches for IA64 [just the last patch 7/7]cpu_present_map.patch
    ... please replace the last patch cpu_present_map with this attached patch. ... Before cpu hotplug was introduced cpu_possible ... extern unsigned long ap_wakeup_vector; +#ifdef CONFIG_HOTPLUG_CPU +extern cpumask_t cpu_possible_map; ...
    (Linux-Kernel)
  • Re: RT patch acceptance (scheduler)
    ... > lock up the CPU in IRQ mode for human-perceptible time, ... For non-DMA IDE access data copies are CPU driven ... which can create tons of latency problems for that case. ... I suggest that you read the patch for the answer to softirq ...
    (Linux-Kernel)
  • Re: better wake-balancing: respin
    ... >>I guess I missed the objection for dropping the patch. ... correlation between the CPU the interrupt arrives on and the CPU the ... There is no point in immediate balancing either: ... If this patch hurts other workloads (and please ...
    (Linux-Kernel)
  • [PATCH] v5 Teach RCU that idle task is not quiscent state at boot
    ... The boot CPU runs in the context of its idle thread during boot-up. ... RCU to prematurely end grace periods during this time. ... This patch changes the rcutree.c and rcuclassic.c rcu_check_callbacks ...
    (Linux-Kernel)