Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Len Brown | 888ba6c | 2005-08-24 12:07:20 -0400 | [diff] [blame] | 39 | #ifdef CONFIG_ACPI |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 40 | /* |
| 41 | * If CPEI cannot be re-targetted, and this is |
| 42 | * CPEI target, then dont create the control file |
| 43 | */ |
| 44 | if (!can_cpei_retarget() && is_cpu_cpei_target(num)) |
| 45 | sysfs_cpus[num].cpu.no_control = 1; |
Ian Wienand | 46906c4 | 2005-07-13 21:09:00 -0700 | [diff] [blame] | 46 | #endif |
Ashok Raj | 55e59c5 | 2005-03-31 22:51:10 -0500 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | return register_cpu(&sysfs_cpus[num].cpu, num, parent); |
| 49 | } |
| 50 | |
| 51 | #ifdef CONFIG_HOTPLUG_CPU |
| 52 | |
| 53 | void arch_unregister_cpu(int num) |
| 54 | { |
| 55 | struct node *parent = NULL; |
| 56 | |
| 57 | #ifdef CONFIG_NUMA |
| 58 | int node = cpu_to_node(num); |
| 59 | parent = &sysfs_nodes[node]; |
| 60 | #endif /* CONFIG_NUMA */ |
| 61 | |
| 62 | return unregister_cpu(&sysfs_cpus[num].cpu, parent); |
| 63 | } |
| 64 | EXPORT_SYMBOL(arch_register_cpu); |
| 65 | EXPORT_SYMBOL(arch_unregister_cpu); |
| 66 | #endif /*CONFIG_HOTPLUG_CPU*/ |
| 67 | |
| 68 | |
| 69 | static int __init topology_init(void) |
| 70 | { |
| 71 | int i, err = 0; |
| 72 | |
| 73 | #ifdef CONFIG_NUMA |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 74 | sysfs_nodes = kzalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | if (!sysfs_nodes) { |
| 76 | err = -ENOMEM; |
| 77 | goto out; |
| 78 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 80 | /* |
| 81 | * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? |
| 82 | */ |
| 83 | for_each_online_node(i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | if ((err = register_node(&sysfs_nodes[i], i, 0))) |
| 85 | goto out; |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 86 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | #endif |
| 88 | |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 89 | sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | if (!sysfs_cpus) { |
| 91 | err = -ENOMEM; |
| 92 | goto out; |
| 93 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 95 | for_each_present_cpu(i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | if((err = arch_register_cpu(i))) |
| 97 | goto out; |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 98 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | out: |
| 100 | return err; |
| 101 | } |
| 102 | |
Zhang, Yanmin | 69dcc99 | 2006-02-03 03:04:36 -0800 | [diff] [blame^] | 103 | subsys_initcall(topology_init); |