topology.c (1005B)
1// SPDX-License-Identifier: GPL-2.0 2#include <linux/cpu.h> 3#include <linux/cpumask.h> 4#include <linux/init.h> 5#include <linux/node.h> 6#include <linux/nodemask.h> 7#include <linux/percpu.h> 8 9static DEFINE_PER_CPU(struct cpu, cpu_devices); 10 11#ifdef CONFIG_HOTPLUG_CPU 12int arch_register_cpu(int cpu) 13{ 14 int ret; 15 struct cpu *c = &per_cpu(cpu_devices, cpu); 16 17 c->hotpluggable = 1; 18 ret = register_cpu(c, cpu); 19 if (ret < 0) 20 pr_warn("register_cpu %d failed (%d)\n", cpu, ret); 21 22 return ret; 23} 24EXPORT_SYMBOL(arch_register_cpu); 25 26void arch_unregister_cpu(int cpu) 27{ 28 struct cpu *c = &per_cpu(cpu_devices, cpu); 29 30 c->hotpluggable = 0; 31 unregister_cpu(c); 32} 33EXPORT_SYMBOL(arch_unregister_cpu); 34#endif 35 36static int __init topology_init(void) 37{ 38 int i, ret; 39 40 for_each_present_cpu(i) { 41 struct cpu *c = &per_cpu(cpu_devices, i); 42 43 c->hotpluggable = !!i; 44 ret = register_cpu(c, i); 45 if (ret < 0) 46 pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret); 47 } 48 49 return 0; 50} 51 52subsys_initcall(topology_init);