All of lore.kernel.org
 help / color / mirror / Atom feed
From: "bibo,mao" <bibo.mao@intel.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "tony.luck@intel.com" <tony.luck@intel.com>,
	Andrew Morton <akpm@osdl.org>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, GOTO <y-goto@jp.fujitsu.com>
Subject: Re: [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map
Date: Tue, 26 Sep 2006 11:23:05 +0000	[thread overview]
Message-ID: <45190D99.20605@intel.com> (raw)
In-Reply-To: <20060922152702.4b01c192.kamezawa.hiroyu@jp.fujitsu.com>

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@jp.fujitsu.com>
> 
> 
>  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

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

WARNING: multiple messages have this Message-ID (diff)
From: "bibo,mao" <bibo.mao@intel.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "tony.luck@intel.com" <tony.luck@intel.com>,
	Andrew Morton <akpm@osdl.org>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, GOTO <y-goto@jp.fujitsu.com>
Subject: Re: [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu to node
Date: Tue, 26 Sep 2006 19:23:05 +0800	[thread overview]
Message-ID: <45190D99.20605@intel.com> (raw)
In-Reply-To: <20060922152702.4b01c192.kamezawa.hiroyu@jp.fujitsu.com>

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@jp.fujitsu.com>
> 
> 
>  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

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

  reply	other threads:[~2006-09-26 11:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-22  6:24 [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] KAMEZAWA Hiroyuki
2006-09-22  6:24 ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node KAMEZAWA Hiroyuki
2006-09-22  6:27 ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu KAMEZAWA Hiroyuki
2006-09-22  6:27   ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu to node KAMEZAWA Hiroyuki
2006-09-26 11:23   ` bibo,mao [this message]
2006-09-26 11:23     ` bibo,mao
2006-09-26 11:39     ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map KAMEZAWA Hiroyuki
2006-09-26 11:39       ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu to node KAMEZAWA Hiroyuki
2006-09-26 11:48       ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map bibo,mao
2006-09-26 11:48         ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [2/2] map cpu to node bibo,mao
2006-09-23  0:06 ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] Andrew Morton
2006-09-23  0:06   ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node Andrew Morton
2006-09-23  0:06   ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] Andrew Morton
2006-09-23  0:06     ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node Andrew Morton
2006-09-23  0:07   ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] Andrew Morton
2006-09-23  0:07     ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node Andrew Morton
2006-09-23  1:06   ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] KAMEZAWA Hiroyuki
2006-09-23  1:06     ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node KAMEZAWA Hiroyuki
2006-09-23  1:11     ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] KAMEZAWA Hiroyuki
2006-09-23  1:11       ` [BUGFIX][PATCH] cpu to node relationship fixup take2 [1/2] acpi_map_cpu2node KAMEZAWA Hiroyuki

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=45190D99.20605@intel.com \
    --to=bibo.mao@intel.com \
    --cc=akpm@osdl.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --cc=y-goto@jp.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.