29 #include <linux/module.h>
33 #define define_one_ro_named(_name, _func) \
34 static DEVICE_ATTR(_name, 0444, _func, NULL)
36 #define define_one_ro(_name) \
37 static DEVICE_ATTR(_name, 0444, show_##_name, NULL)
39 #define define_id_show_func(name) \
40 static ssize_t show_##name(struct device *dev, \
41 struct device_attribute *attr, char *buf) \
43 unsigned int cpu = dev->id; \
44 return sprintf(buf, "%d\n", topology_##name(cpu)); \
47 #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \
48 defined(topology_book_cpumask)
56 cpulist_scnprintf(buf, len-2, mask) :
57 cpumask_scnprintf(buf, len-2, mask);
65 #ifdef arch_provides_topology_pointers
66 #define define_siblings_show_map(name) \
67 static ssize_t show_##name(struct device *dev, \
68 struct device_attribute *attr, char *buf) \
70 unsigned int cpu = dev->id; \
71 return show_cpumap(0, topology_##name(cpu), buf); \
74 #define define_siblings_show_list(name) \
75 static ssize_t show_##name##_list(struct device *dev, \
76 struct device_attribute *attr, \
79 unsigned int cpu = dev->id; \
80 return show_cpumap(1, topology_##name(cpu), buf); \
84 #define define_siblings_show_map(name) \
85 static ssize_t show_##name(struct device *dev, \
86 struct device_attribute *attr, char *buf) \
88 return show_cpumap(0, topology_##name(dev->id), buf); \
91 #define define_siblings_show_list(name) \
92 static ssize_t show_##name##_list(struct device *dev, \
93 struct device_attribute *attr, \
96 return show_cpumap(1, topology_##name(dev->id), buf); \
100 #define define_siblings_show_func(name) \
101 define_siblings_show_map(name); define_siblings_show_list(name)
117 #ifdef CONFIG_SCHED_BOOK
125 static struct attribute *default_attrs[] = {
126 &dev_attr_physical_package_id.attr,
127 &dev_attr_core_id.attr,
128 &dev_attr_thread_siblings.attr,
129 &dev_attr_thread_siblings_list.attr,
130 &dev_attr_core_siblings.attr,
131 &dev_attr_core_siblings_list.attr,
132 #ifdef CONFIG_SCHED_BOOK
133 &dev_attr_book_id.attr,
134 &dev_attr_book_siblings.attr,
135 &dev_attr_book_siblings_list.attr,
141 .attrs = default_attrs,
153 static void __cpuinit topology_remove_dev(
unsigned int cpu)
161 unsigned long action,
void *hcpu)
163 unsigned int cpu = (
unsigned long)hcpu;
169 rc = topology_add_dev(cpu);
175 topology_remove_dev(cpu);
178 return notifier_from_errno(rc);
181 static int __cpuinit topology_sysfs_init(
void)
187 rc = topology_add_dev(cpu);