From: Paul Mundt <lethal@linux-sh.org>
To: linux-kernel@vger.kernel.org
Subject: Re: [v2,5/8] NUMA Hotplug emulator
Date: Mon, 15 Nov 2010 15:58:47 +0900 [thread overview]
Message-ID: <20101115065847.GH8489@linux-sh.org> (raw)
In-Reply-To: <20101113061611.GO32501@shaohui>
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);
next prev parent reply other threads:[~2010-11-15 6:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-13 6:16 [v2,5/8] NUMA Hotplug emulator Shaohui Zheng
2010-11-15 6:58 ` Paul Mundt [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-11-16 4:13 Shaohui Zheng
2010-11-16 5:47 ` Paul Mundt
[not found] ` <A24AE1FFE7AEC5489F83450EE98351BF27D53BCC36@shsmsx502.ccr.corp.intel.com>
2010-11-16 5:05 ` Shaohui Zheng
2010-11-16 7:04 ` Paul Mundt
2010-11-16 6:21 ` Shaohui Zheng
2010-11-13 5:42 Shaohui Zheng
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=20101115065847.GH8489@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
/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.