]> err.no Git - linux-2.6/blob - arch/ia64/kernel/topology.c
Merge with rsync://fileserver/linux
[linux-2.6] / arch / ia64 / kernel / topology.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * This file contains NUMA specific variables and functions which can
7  * be split away from DISCONTIGMEM and are used on NUMA machines with
8  * contiguous memory.
9  *              2002/08/07 Erich Focht <efocht@ess.nec.de>
10  * Populate cpu entries in sysfs for non-numa systems as well
11  *      Intel Corporation - Ashok Raj
12  */
13
14 #include <linux/config.h>
15 #include <linux/cpu.h>
16 #include <linux/kernel.h>
17 #include <linux/mm.h>
18 #include <linux/node.h>
19 #include <linux/init.h>
20 #include <linux/bootmem.h>
21 #include <linux/nodemask.h>
22 #include <asm/mmzone.h>
23 #include <asm/numa.h>
24 #include <asm/cpu.h>
25
26 #ifdef CONFIG_NUMA
27 static struct node *sysfs_nodes;
28 #endif
29 static struct ia64_cpu *sysfs_cpus;
30
31 int arch_register_cpu(int num)
32 {
33         struct node *parent = NULL;
34         
35 #ifdef CONFIG_NUMA
36         parent = &sysfs_nodes[cpu_to_node(num)];
37 #endif /* CONFIG_NUMA */
38
39         /*
40          * If CPEI cannot be re-targetted, and this is
41          * CPEI target, then dont create the control file
42          */
43         if (!can_cpei_retarget() && is_cpu_cpei_target(num))
44                 sysfs_cpus[num].cpu.no_control = 1;
45
46         return register_cpu(&sysfs_cpus[num].cpu, num, parent);
47 }
48
49 #ifdef CONFIG_HOTPLUG_CPU
50
51 void arch_unregister_cpu(int num)
52 {
53         struct node *parent = NULL;
54
55 #ifdef CONFIG_NUMA
56         int node = cpu_to_node(num);
57         parent = &sysfs_nodes[node];
58 #endif /* CONFIG_NUMA */
59
60         return unregister_cpu(&sysfs_cpus[num].cpu, parent);
61 }
62 EXPORT_SYMBOL(arch_register_cpu);
63 EXPORT_SYMBOL(arch_unregister_cpu);
64 #endif /*CONFIG_HOTPLUG_CPU*/
65
66
67 static int __init topology_init(void)
68 {
69         int i, err = 0;
70
71 #ifdef CONFIG_NUMA
72         sysfs_nodes = kmalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL);
73         if (!sysfs_nodes) {
74                 err = -ENOMEM;
75                 goto out;
76         }
77         memset(sysfs_nodes, 0, sizeof(struct node) * MAX_NUMNODES);
78
79         /* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? */
80         for_each_online_node(i)
81                 if ((err = register_node(&sysfs_nodes[i], i, 0)))
82                         goto out;
83 #endif
84
85         sysfs_cpus = kmalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
86         if (!sysfs_cpus) {
87                 err = -ENOMEM;
88                 goto out;
89         }
90         memset(sysfs_cpus, 0, sizeof(struct ia64_cpu) * NR_CPUS);
91
92         for_each_present_cpu(i)
93                 if((err = arch_register_cpu(i)))
94                         goto out;
95 out:
96         return err;
97 }
98
99 __initcall(topology_init);