Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30734
b: refs/heads/master
c: 76b67ed
h: refs/heads/master
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Jun 28, 2006
1 parent 63f4a2a commit 8774592
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 70 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dd0932d9d4301bd58a4d5a634a3a8298c4fc5e24
refs/heads/master: 76b67ed9dce69a6a329cdd66f94af1787f417b62
2 changes: 1 addition & 1 deletion trunk/arch/alpha/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ register_cpus(void)
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
register_cpu(p, i, NULL);
register_cpu(p, i);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ static int __init topology_init(void)
int cpu;

for_each_possible_cpu(cpu)
register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu, NULL);
register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu);

return 0;
}
Expand Down
23 changes: 4 additions & 19 deletions trunk/arch/i386/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,8 @@

static struct i386_cpu cpu_devices[NR_CPUS];

int arch_register_cpu(int num){
struct node *parent = NULL;

#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
if (node_online(node))
parent = &node_devices[parent_node(node)];
#endif /* CONFIG_NUMA */

int arch_register_cpu(int num)
{
/*
* CPU0 cannot be offlined due to several
* restrictions and assumptions in kernel. This basically
Expand All @@ -50,21 +43,13 @@ int arch_register_cpu(int num){
if (!num)
cpu_devices[num].cpu.no_control = 1;

return register_cpu(&cpu_devices[num].cpu, num, parent);
return register_cpu(&cpu_devices[num].cpu, num);
}

#ifdef CONFIG_HOTPLUG_CPU

void arch_unregister_cpu(int num) {
struct node *parent = NULL;

#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
if (node_online(node))
parent = &node_devices[parent_node(node)];
#endif /* CONFIG_NUMA */

return unregister_cpu(&cpu_devices[num].cpu, parent);
return unregister_cpu(&cpu_devices[num].cpu);
}
EXPORT_SYMBOL(arch_register_cpu);
EXPORT_SYMBOL(arch_unregister_cpu);
Expand Down
17 changes: 2 additions & 15 deletions trunk/arch/ia64/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ static struct ia64_cpu *sysfs_cpus;

int arch_register_cpu(int num)
{
struct node *parent = NULL;

#ifdef CONFIG_NUMA
parent = &node_devices[cpu_to_node(num)];
#endif /* CONFIG_NUMA */

#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
/*
* If CPEI cannot be re-targetted, and this is
Expand All @@ -45,21 +39,14 @@ int arch_register_cpu(int num)
sysfs_cpus[num].cpu.no_control = 1;
#endif

return register_cpu(&sysfs_cpus[num].cpu, num, parent);
return register_cpu(&sysfs_cpus[num].cpu, num);
}

#ifdef CONFIG_HOTPLUG_CPU

void arch_unregister_cpu(int num)
{
struct node *parent = NULL;

#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
parent = &node_devices[node];
#endif /* CONFIG_NUMA */

return unregister_cpu(&sysfs_cpus[num].cpu, parent);
return unregister_cpu(&sysfs_cpus[num].cpu);
}
EXPORT_SYMBOL(arch_register_cpu);
EXPORT_SYMBOL(arch_unregister_cpu);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/m32r/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static int __init topology_init(void)
int i;

for_each_present_cpu(i)
register_cpu(&cpu_devices[i], i, NULL);
register_cpu(&cpu_devices[i], i);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/mips/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static int __init topology_init(void)
int ret;

for_each_present_cpu(cpu) {
ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL);
ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
if (ret)
printk(KERN_WARNING "topology_init: register_cpu %d "
"failed (%d)\n", cpu, ret);
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/parisc/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ static struct cpu cpu_devices[NR_CPUS] __read_mostly;

static int __init topology_init(void)
{
struct node *parent = NULL;
int num;

for_each_present_cpu(num) {
register_cpu(&cpu_devices[num], num, parent);
register_cpu(&cpu_devices[num], num);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/powerpc/kernel/setup_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int __init ppc_init(void)

/* register CPU devices */
for_each_possible_cpu(i)
register_cpu(&cpu_devices[i], i, NULL);
register_cpu(&cpu_devices[i], i);

/* call platform init */
if (ppc_md.init != NULL) {
Expand Down
12 changes: 1 addition & 11 deletions trunk/arch/powerpc/kernel/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,13 @@ static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
static int __init topology_init(void)
{
int cpu;
struct node *parent = NULL;

register_nodes();

register_cpu_notifier(&sysfs_cpu_nb);

for_each_possible_cpu(cpu) {
struct cpu *c = &per_cpu(cpu_devices, cpu);

#ifdef CONFIG_NUMA
/* The node to which a cpu belongs can't be known
* until the cpu is made present.
*/
parent = NULL;
if (cpu_present(cpu))
parent = &node_devices[cpu_to_node(cpu)];
#endif
/*
* For now, we just see if the system supports making
* the RTAS calls for CPU hotplug. But, there may be a
Expand All @@ -376,7 +366,7 @@ static int __init topology_init(void)
c->no_control = 1;

if (cpu_online(cpu) || (c->no_control == 0)) {
register_cpu(c, cpu, parent);
register_cpu(c, cpu);

sysdev_create_file(&c->sysdev, &attr_physical_id);
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/ppc/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ int __init ppc_init(void)

/* register CPU devices */
for_each_possible_cpu(i)
register_cpu(&cpu_devices[i], i, NULL);
register_cpu(&cpu_devices[i], i);

/* call platform init */
if (ppc_md.init != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/s390/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ static int __init topology_init(void)
int ret;

for_each_possible_cpu(cpu) {
ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL);
ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu);
if (ret)
printk(KERN_WARNING "topology_init: register_cpu %d "
"failed (%d)\n", cpu, ret);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/sh/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ static int __init topology_init(void)
int cpu_id;

for_each_possible_cpu(cpu_id)
register_cpu(&cpu[cpu_id], cpu_id, NULL);
register_cpu(&cpu[cpu_id], cpu_id);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/sh64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static struct cpu cpu[1];

static int __init topology_init(void)
{
return register_cpu(cpu, 0, NULL);
return register_cpu(cpu, 0);
}

subsys_initcall(topology_init);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/sparc64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static int __init topology_init(void)
for_each_possible_cpu(i) {
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
if (p) {
register_cpu(p, i, NULL);
register_cpu(p, i);
err = 0;
}
}
Expand Down
18 changes: 8 additions & 10 deletions trunk/drivers/base/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/cpu.h>
#include <linux/topology.h>
#include <linux/device.h>
#include <linux/node.h>

#include "base.h"

Expand Down Expand Up @@ -57,13 +58,12 @@ static void __devinit register_cpu_control(struct cpu *cpu)
{
sysdev_create_file(&cpu->sysdev, &attr_online);
}
void unregister_cpu(struct cpu *cpu, struct node *root)
void unregister_cpu(struct cpu *cpu)
{
int logical_cpu = cpu->sysdev.id;

if (root)
sysfs_remove_link(&root->sysdev.kobj,
kobject_name(&cpu->sysdev.kobj));
unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));

sysdev_remove_file(&cpu->sysdev, &attr_online);

sysdev_unregister(&cpu->sysdev);
Expand Down Expand Up @@ -109,23 +109,21 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
*
* Initialize and register the CPU device.
*/
int __devinit register_cpu(struct cpu *cpu, int num, struct node *root)
int __devinit register_cpu(struct cpu *cpu, int num)
{
int error;

cpu->node_id = cpu_to_node(num);
cpu->sysdev.id = num;
cpu->sysdev.cls = &cpu_sysdev_class;

error = sysdev_register(&cpu->sysdev);
if (!error && root)
error = sysfs_create_link(&root->sysdev.kobj,
&cpu->sysdev.kobj,
kobject_name(&cpu->sysdev.kobj));

if (!error && !cpu->no_control)
register_cpu_control(cpu);
if (!error)
cpu_sys_devices[num] = &cpu->sysdev;
if (!error)
register_cpu_under_node(num, cpu_to_node(num));

#ifdef CONFIG_KEXEC
if (!error)
Expand Down
36 changes: 36 additions & 0 deletions trunk/drivers/base/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/cpumask.h>
#include <linux/topology.h>
#include <linux/nodemask.h>
#include <linux/cpu.h>

static struct sysdev_class node_class = {
set_kset_name("node"),
Expand Down Expand Up @@ -192,9 +193,38 @@ void unregister_node(struct node *node)

struct node node_devices[MAX_NUMNODES];

/*
* register cpu under node
*/
int register_cpu_under_node(unsigned int cpu, unsigned int nid)
{
if (node_online(nid)) {
struct sys_device *obj = get_cpu_sysdev(cpu);
if (!obj)
return 0;
return sysfs_create_link(&node_devices[nid].sysdev.kobj,
&obj->kobj,
kobject_name(&obj->kobj));
}

return 0;
}

int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
{
if (node_online(nid)) {
struct sys_device *obj = get_cpu_sysdev(cpu);
if (obj)
sysfs_remove_link(&node_devices[nid].sysdev.kobj,
kobject_name(&obj->kobj));
}
return 0;
}

int register_one_node(int nid)
{
int error = 0;
int cpu;

if (node_online(nid)) {
int p_node = parent_node(nid);
Expand All @@ -204,6 +234,12 @@ int register_one_node(int nid)
parent = &node_devices[p_node];

error = register_node(&node_devices[nid], nid, parent);

/* link cpu under this node */
for_each_present_cpu(cpu) {
if (cpu_to_node(cpu) == nid)
register_cpu_under_node(cpu, nid);
}
}

return error;
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/linux/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ struct cpu {
struct sys_device sysdev;
};

extern int register_cpu(struct cpu *, int, struct node *);
extern int register_cpu(struct cpu *cpu, int num);
extern struct sys_device *get_cpu_sysdev(unsigned cpu);
#ifdef CONFIG_HOTPLUG_CPU
extern void unregister_cpu(struct cpu *, struct node *);
extern void unregister_cpu(struct cpu *cpu);
#endif
struct notifier_block;

Expand Down
13 changes: 13 additions & 0 deletions trunk/include/linux/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ extern int register_node(struct node *, int, struct node *);
extern void unregister_node(struct node *node);
extern int register_one_node(int nid);
extern void unregister_one_node(int nid);
#ifdef CONFIG_NUMA
extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
#else
static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
{
return 0;
}
static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
{
return 0;
}
#endif

#define to_node(sys_device) container_of(sys_device, struct node, sysdev)

Expand Down

0 comments on commit 8774592

Please sign in to comment.