Blame view
drivers/base/topology.c
3.88 KB
989d42e85 driver core: add ... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
69dcc9919 [PATCH] Export cp... |
2 3 4 5 6 7 8 9 |
/* * driver/base/topology.c - Populate sysfs with cpu topology information * * Written by: Zhang Yanmin, Intel Corporation * * Copyright (C) 2006, Intel Corp. * * All rights reserved. |
69dcc9919 [PATCH] Export cp... |
10 |
*/ |
69dcc9919 [PATCH] Export cp... |
11 12 13 |
#include <linux/mm.h> #include <linux/cpu.h> #include <linux/module.h> |
b13d3720e topology: Fix spa... |
14 |
#include <linux/hardirq.h> |
69dcc9919 [PATCH] Export cp... |
15 |
#include <linux/topology.h> |
948b3edba drivers core: Mis... |
16 17 18 19 20 21 |
#define define_id_show_func(name) \ static ssize_t name##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ return sysfs_emit(buf, "%d ", topology_##name(dev->id)); \ |
69dcc9919 [PATCH] Export cp... |
22 |
} |
d6ea8d01d topology: replace... |
23 24 |
#define define_siblings_show_map(name, mask) \ static ssize_t name##_show(struct device *dev, \ |
8a25a2fd1 cpu: convert 'cpu... |
25 |
struct device_attribute *attr, char *buf) \ |
23ca4bba3 x86: cleanup earl... |
26 |
{ \ |
d6ea8d01d topology: replace... |
27 |
return cpumap_print_to_pagebuf(false, buf, topology_##mask(dev->id));\ |
23ca4bba3 x86: cleanup earl... |
28 |
} |
d6ea8d01d topology: replace... |
29 30 31 32 |
#define define_siblings_show_list(name, mask) \ static ssize_t name##_list_show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ |
23ca4bba3 x86: cleanup earl... |
33 |
{ \ |
d6ea8d01d topology: replace... |
34 |
return cpumap_print_to_pagebuf(true, buf, topology_##mask(dev->id));\ |
23ca4bba3 x86: cleanup earl... |
35 |
} |
23ca4bba3 x86: cleanup earl... |
36 |
|
d6ea8d01d topology: replace... |
37 38 39 |
#define define_siblings_show_func(name, mask) \ define_siblings_show_map(name, mask); \ define_siblings_show_list(name, mask) |
39106dcf8 cpumask: use new ... |
40 |
|
69dcc9919 [PATCH] Export cp... |
41 |
define_id_show_func(physical_package_id); |
d6ea8d01d topology: replace... |
42 |
static DEVICE_ATTR_RO(physical_package_id); |
69dcc9919 [PATCH] Export cp... |
43 |
|
0e344d8c7 cpu/topology: Exp... |
44 45 |
define_id_show_func(die_id); static DEVICE_ATTR_RO(die_id); |
69dcc9919 [PATCH] Export cp... |
46 |
define_id_show_func(core_id); |
d6ea8d01d topology: replace... |
47 |
static DEVICE_ATTR_RO(core_id); |
69dcc9919 [PATCH] Export cp... |
48 |
|
06931e622 sched/topology: R... |
49 |
define_siblings_show_func(thread_siblings, sibling_cpumask); |
d6ea8d01d topology: replace... |
50 51 |
static DEVICE_ATTR_RO(thread_siblings); static DEVICE_ATTR_RO(thread_siblings_list); |
69dcc9919 [PATCH] Export cp... |
52 |
|
2e4c54dac topology: Create ... |
53 54 55 |
define_siblings_show_func(core_cpus, sibling_cpumask); static DEVICE_ATTR_RO(core_cpus); static DEVICE_ATTR_RO(core_cpus_list); |
d6ea8d01d topology: replace... |
56 57 58 |
define_siblings_show_func(core_siblings, core_cpumask); static DEVICE_ATTR_RO(core_siblings); static DEVICE_ATTR_RO(core_siblings_list); |
69dcc9919 [PATCH] Export cp... |
59 |
|
2e4c54dac topology: Create ... |
60 61 62 |
define_siblings_show_func(die_cpus, die_cpumask); static DEVICE_ATTR_RO(die_cpus); static DEVICE_ATTR_RO(die_cpus_list); |
b73ed8dc0 topology: Create ... |
63 64 65 |
define_siblings_show_func(package_cpus, core_cpumask); static DEVICE_ATTR_RO(package_cpus); static DEVICE_ATTR_RO(package_cpus_list); |
b40d8ed4e topology/sysfs: P... |
66 67 |
#ifdef CONFIG_SCHED_BOOK define_id_show_func(book_id); |
d6ea8d01d topology: replace... |
68 69 70 71 |
static DEVICE_ATTR_RO(book_id); define_siblings_show_func(book_siblings, book_cpumask); static DEVICE_ATTR_RO(book_siblings); static DEVICE_ATTR_RO(book_siblings_list); |
b40d8ed4e topology/sysfs: P... |
72 |
#endif |
a62247e1f topology/sysfs: p... |
73 74 75 76 77 78 79 |
#ifdef CONFIG_SCHED_DRAWER define_id_show_func(drawer_id); static DEVICE_ATTR_RO(drawer_id); define_siblings_show_func(drawer_siblings, drawer_cpumask); static DEVICE_ATTR_RO(drawer_siblings); static DEVICE_ATTR_RO(drawer_siblings_list); #endif |
69dcc9919 [PATCH] Export cp... |
80 |
static struct attribute *default_attrs[] = { |
8a25a2fd1 cpu: convert 'cpu... |
81 |
&dev_attr_physical_package_id.attr, |
0e344d8c7 cpu/topology: Exp... |
82 |
&dev_attr_die_id.attr, |
8a25a2fd1 cpu: convert 'cpu... |
83 84 85 |
&dev_attr_core_id.attr, &dev_attr_thread_siblings.attr, &dev_attr_thread_siblings_list.attr, |
2e4c54dac topology: Create ... |
86 87 |
&dev_attr_core_cpus.attr, &dev_attr_core_cpus_list.attr, |
8a25a2fd1 cpu: convert 'cpu... |
88 89 |
&dev_attr_core_siblings.attr, &dev_attr_core_siblings_list.attr, |
2e4c54dac topology: Create ... |
90 91 |
&dev_attr_die_cpus.attr, &dev_attr_die_cpus_list.attr, |
b73ed8dc0 topology: Create ... |
92 93 |
&dev_attr_package_cpus.attr, &dev_attr_package_cpus_list.attr, |
b40d8ed4e topology/sysfs: P... |
94 |
#ifdef CONFIG_SCHED_BOOK |
8a25a2fd1 cpu: convert 'cpu... |
95 96 97 |
&dev_attr_book_id.attr, &dev_attr_book_siblings.attr, &dev_attr_book_siblings_list.attr, |
b40d8ed4e topology/sysfs: P... |
98 |
#endif |
a62247e1f topology/sysfs: p... |
99 100 101 102 103 |
#ifdef CONFIG_SCHED_DRAWER &dev_attr_drawer_id.attr, &dev_attr_drawer_siblings.attr, &dev_attr_drawer_siblings_list.attr, #endif |
69dcc9919 [PATCH] Export cp... |
104 105 |
NULL }; |
df44d30d2 base: topology: c... |
106 |
static const struct attribute_group topology_attr_group = { |
69dcc9919 [PATCH] Export cp... |
107 108 109 110 111 |
.attrs = default_attrs, .name = "topology" }; /* Add/Remove cpu_topology interface for CPU device */ |
a83048ebd drivers: delete _... |
112 |
static int topology_add_dev(unsigned int cpu) |
69dcc9919 [PATCH] Export cp... |
113 |
{ |
8a25a2fd1 cpu: convert 'cpu... |
114 |
struct device *dev = get_cpu_device(cpu); |
06a4bcae1 cpu topology: con... |
115 |
|
8a25a2fd1 cpu: convert 'cpu... |
116 |
return sysfs_create_group(&dev->kobj, &topology_attr_group); |
69dcc9919 [PATCH] Export cp... |
117 |
} |
38643a0e6 drivers base/topo... |
118 |
static int topology_remove_dev(unsigned int cpu) |
69dcc9919 [PATCH] Export cp... |
119 |
{ |
8a25a2fd1 cpu: convert 'cpu... |
120 |
struct device *dev = get_cpu_device(cpu); |
06a4bcae1 cpu topology: con... |
121 |
|
8a25a2fd1 cpu: convert 'cpu... |
122 |
sysfs_remove_group(&dev->kobj, &topology_attr_group); |
38643a0e6 drivers base/topo... |
123 |
return 0; |
69dcc9919 [PATCH] Export cp... |
124 |
} |
69dcc9919 [PATCH] Export cp... |
125 |
|
0d989da36 topology: mark a ... |
126 |
static int __init topology_sysfs_init(void) |
69dcc9919 [PATCH] Export cp... |
127 |
{ |
38643a0e6 drivers base/topo... |
128 129 130 |
return cpuhp_setup_state(CPUHP_TOPOLOGY_PREPARE, "base/topology:prepare", topology_add_dev, topology_remove_dev); |
69dcc9919 [PATCH] Export cp... |
131 132 133 |
} device_initcall(topology_sysfs_init); |