static int __init topology_init(void) { int i, ret; #ifdef CONFIG_NEED_MULTIPLE_NODES for_each_online_node(i) register_one_node(i); #endif for_each_present_cpu(i) { ret = register_cpu(&per_cpu(cpu_devices, i), i); if (unlikely(ret)) printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n", __FUNCTION__, i, ret); } #if defined(CONFIG_NUMA) && !defined(CONFIG_SMP) /* * In the UP case, make sure the CPU association is still * registered under each node. Without this, sysfs fails * to make the connection between nodes other than node0 * and cpu0. */ for_each_online_node(i) if (i != numa_node_id()) register_cpu_under_node(raw_smp_processor_id(), i); #endif return 0; }
int register_one_node(int nid) { int error = 0; int cpu; if (node_online(nid)) { int p_node = parent_node(nid); struct node *parent = NULL; if (p_node != nid) parent = node_devices[p_node]; node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL); if (!node_devices[nid]) return -ENOMEM; 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); } /* link memory sections under this node */ error = link_mem_sections(nid); /* initialize work queue for memory hot plug */ init_node_hugetlb_work(nid); } return error; }
static int __init topology_init(void) { int i, ret; #ifdef CONFIG_NEED_MULTIPLE_NODES for_each_online_node(i) register_one_node(i); #endif for_each_present_cpu(i) { struct cpu *c = &per_cpu(cpu_devices, i); c->hotpluggable = 1; ret = register_cpu(c, i); if (unlikely(ret)) printk(KERN_WARNING "%s: register_cpu %d failed (%d)\n", __func__, i, ret); } #if defined(CONFIG_NUMA) && !defined(CONFIG_SMP) for_each_online_node(i) if (i != numa_node_id()) register_cpu_under_node(raw_smp_processor_id(), i); #endif return 0; }
int register_one_node(int nid) { int error = 0; int cpu; if (node_online(nid)) { int p_node = parent_node(nid); struct node *parent = NULL; if (p_node != 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); } /* link memory sections under this node */ error = link_mem_sections(nid); } return error; }
static void change_cpu_under_node(struct cpu *cpu, unsigned int from_nid, unsigned int to_nid) { int cpuid = cpu->dev.id; unregister_cpu_under_node(cpuid, from_nid); register_cpu_under_node(cpuid, to_nid); cpu->node_id = to_nid; }
/* * register_cpu - Setup a driverfs device for a CPU. * @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. * * Initialize and register the CPU device. */ 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 && cpu->hotpluggable) 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) error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes); #endif return error; }
int __register_one_node(int nid) { int error; int cpu; node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL); if (!node_devices[nid]) return -ENOMEM; error = register_node(node_devices[nid], nid); /* link cpu under this node */ for_each_present_cpu(cpu) { if (cpu_to_node(cpu) == nid) register_cpu_under_node(cpu, nid); } /* initialize work queue for memory hot plug */ init_node_hugetlb_work(nid); return error; }