android_kernel_xiaomi_sm8350/arch/ia64/kernel/topology.c
Linus Torvalds 1da177e4c3 Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
2005-04-16 15:20:36 -07:00

93 lines
2.1 KiB
C

/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* This file contains NUMA specific variables and functions which can
* be split away from DISCONTIGMEM and are used on NUMA machines with
* contiguous memory.
* 2002/08/07 Erich Focht <efocht@ess.nec.de>
* Populate cpu entries in sysfs for non-numa systems as well
* Intel Corporation - Ashok Raj
*/
#include <linux/config.h>
#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/node.h>
#include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/nodemask.h>
#include <asm/mmzone.h>
#include <asm/numa.h>
#include <asm/cpu.h>
#ifdef CONFIG_NUMA
static struct node *sysfs_nodes;
#endif
static struct ia64_cpu *sysfs_cpus;
int arch_register_cpu(int num)
{
struct node *parent = NULL;
#ifdef CONFIG_NUMA
parent = &sysfs_nodes[cpu_to_node(num)];
#endif /* CONFIG_NUMA */
return register_cpu(&sysfs_cpus[num].cpu, num, parent);
}
#ifdef CONFIG_HOTPLUG_CPU
void arch_unregister_cpu(int num)
{
struct node *parent = NULL;
#ifdef CONFIG_NUMA
int node = cpu_to_node(num);
parent = &sysfs_nodes[node];
#endif /* CONFIG_NUMA */
return unregister_cpu(&sysfs_cpus[num].cpu, parent);
}
EXPORT_SYMBOL(arch_register_cpu);
EXPORT_SYMBOL(arch_unregister_cpu);
#endif /*CONFIG_HOTPLUG_CPU*/
static int __init topology_init(void)
{
int i, err = 0;
#ifdef CONFIG_NUMA
sysfs_nodes = kmalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL);
if (!sysfs_nodes) {
err = -ENOMEM;
goto out;
}
memset(sysfs_nodes, 0, sizeof(struct node) * MAX_NUMNODES);
/* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? */
for_each_online_node(i)
if ((err = register_node(&sysfs_nodes[i], i, 0)))
goto out;
#endif
sysfs_cpus = kmalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
if (!sysfs_cpus) {
err = -ENOMEM;
goto out;
}
memset(sysfs_cpus, 0, sizeof(struct ia64_cpu) * NR_CPUS);
for_each_present_cpu(i)
if((err = arch_register_cpu(i)))
goto out;
out:
return err;
}
__initcall(topology_init);