lkml.org 
[lkml]   [2010]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [v2,5/8] NUMA Hotplug emulator
On Sat, Nov 13, 2010 at 02:16:11PM +0800, Shaohui Zheng wrote:
> @@ -37,6 +40,11 @@ static DEFINE_PER_CPU(struct x86_cpu, cpu_devices);
> /*
> * Add nid(NUMA node id) as parameter for cpu hotplug emulation. It supports
> * to register a CPU to any nodes.
> + *
> + * nid is a special parameter, it has 2 different branches:
> + * 1) when nid == NUMA_NO_NODE, the CPU will be registered into the normal node
> + * which it should be in.
> + * 2) nid != NUMA_NO_NODE, it will be registered into the specified node.
> */
> static int __ref __arch_register_cpu(int num, int nid)
> {
> @@ -52,8 +60,23 @@ static int __ref __arch_register_cpu(int num, int nid)
> if (num)
> per_cpu(cpu_devices, num).cpu.hotpluggable = 1;
>
> - return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
> + if (nid == NUMA_NO_NODE)
> + return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
> + else
> + return register_cpu_emu(&per_cpu(cpu_devices, num).cpu, num, nid);
> +}
> +
This looks like an incredibly painful interface. How about scrapping all
of this _emu() mess and just reworking the register_cpu() interface?
Something like:

---

drivers/base/cpu.c | 7 ++++---
include/linux/cpu.h | 8 +++++++-
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 251acea..039fd44 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -212,13 +212,14 @@ static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
* @cpu - cpu->hotpluggable field set to 1 will generate a control file in
* sysfs for this CPU.
* @num - CPU number to use when creating the device.
+ * @nid - Node ID to use, if any.
*
* Initialize and register the CPU device.
*/
-int __cpuinit register_cpu(struct cpu *cpu, int num)
+int __cpuinit register_cpu_node(struct cpu *cpu, int num, int nid)
{
int error;
- cpu->node_id = cpu_to_node(num);
+ cpu->node_id = nid;
cpu->sysdev.id = num;
cpu->sysdev.cls = &cpu_sysdev_class;

@@ -229,7 +230,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num)
if (!error)
per_cpu(cpu_sys_devices, num) = &cpu->sysdev;
if (!error)
- register_cpu_under_node(num, cpu_to_node(num));
+ register_cpu_under_node(num, nid);

#ifdef CONFIG_KEXEC
if (!error)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 4823af6..d9e19c8 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -30,7 +30,13 @@ struct cpu {
struct sys_device sysdev;
};

-extern int register_cpu(struct cpu *cpu, int num);
+extern int register_cpu_node(struct cpu *cpu, int num, int nid);
+
+static inline int register_cpu(struct cpu *cpu, int num)
+{
+ return register_cpu_node(cpu, num, cpu_to_node(num));
+}
+
extern struct sys_device *get_cpu_sysdev(unsigned cpu);

extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr);

\
 
 \ /
  Last update: 2010-11-15 08:01    [W:0.045 / U:1.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site