aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cputopology.txt26
-rw-r--r--drivers/base/topology.c32
-rw-r--r--include/linux/topology.h13
3 files changed, 28 insertions, 43 deletions
diff --git a/Documentation/cputopology.txt b/Documentation/cputopology.txt
index b61cb9564023..bd699da24666 100644
--- a/Documentation/cputopology.txt
+++ b/Documentation/cputopology.txt
@@ -14,9 +14,8 @@ represent the thread siblings to cpu X in the same physical package;
14To implement it in an architecture-neutral way, a new source file, 14To implement it in an architecture-neutral way, a new source file,
15drivers/base/topology.c, is to export the 4 attributes. 15drivers/base/topology.c, is to export the 4 attributes.
16 16
17If one architecture wants to support this feature, it just needs to 17For an architecture to support this feature, it must define some of
18implement 4 defines, typically in file include/asm-XXX/topology.h. 18these macros in include/asm-XXX/topology.h:
19The 4 defines are:
20#define topology_physical_package_id(cpu) 19#define topology_physical_package_id(cpu)
21#define topology_core_id(cpu) 20#define topology_core_id(cpu)
22#define topology_thread_siblings(cpu) 21#define topology_thread_siblings(cpu)
@@ -25,17 +24,10 @@ The 4 defines are:
25The type of **_id is int. 24The type of **_id is int.
26The type of siblings is cpumask_t. 25The type of siblings is cpumask_t.
27 26
28To be consistent on all architectures, the 4 attributes should have 27To be consistent on all architectures, include/linux/topology.h
29default values if their values are unavailable. Below is the rule. 28provides default definitions for any of the above macros that are
301) physical_package_id: If cpu has no physical package id, -1 is the 29not defined by include/asm-XXX/topology.h:
31default value. 301) physical_package_id: -1
322) core_id: If cpu doesn't support multi-core, its core id is 0. 312) core_id: 0
333) thread_siblings: Just include itself, if the cpu doesn't support 323) thread_siblings: just the given CPU
34HT/multi-thread. 334) core_siblings: just the given CPU
354) core_siblings: Just include itself, if the cpu doesn't support
36multi-core and HT/Multi-thread.
37
38So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
39
40If an attribute isn't defined on an architecture, it won't be exported.
41
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 1efe162e16d7..3f6d9b0a6abe 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -93,47 +93,27 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
93#define define_siblings_show_func(name) \ 93#define define_siblings_show_func(name) \
94 define_siblings_show_map(name); define_siblings_show_list(name) 94 define_siblings_show_map(name); define_siblings_show_list(name)
95 95
96#ifdef topology_physical_package_id
97define_id_show_func(physical_package_id); 96define_id_show_func(physical_package_id);
98define_one_ro(physical_package_id); 97define_one_ro(physical_package_id);
99#define ref_physical_package_id_attr &attr_physical_package_id.attr,
100#else
101#define ref_physical_package_id_attr
102#endif
103 98
104#ifdef topology_core_id
105define_id_show_func(core_id); 99define_id_show_func(core_id);
106define_one_ro(core_id); 100define_one_ro(core_id);
107#define ref_core_id_attr &attr_core_id.attr,
108#else
109#define ref_core_id_attr
110#endif
111 101
112#ifdef topology_thread_siblings
113define_siblings_show_func(thread_siblings); 102define_siblings_show_func(thread_siblings);
114define_one_ro(thread_siblings); 103define_one_ro(thread_siblings);
115define_one_ro(thread_siblings_list); 104define_one_ro(thread_siblings_list);
116#define ref_thread_siblings_attr \
117 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
118#else
119#define ref_thread_siblings_attr
120#endif
121 105
122#ifdef topology_core_siblings
123define_siblings_show_func(core_siblings); 106define_siblings_show_func(core_siblings);
124define_one_ro(core_siblings); 107define_one_ro(core_siblings);
125define_one_ro(core_siblings_list); 108define_one_ro(core_siblings_list);
126#define ref_core_siblings_attr \
127 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
128#else
129#define ref_core_siblings_attr
130#endif
131 109
132static struct attribute *default_attrs[] = { 110static struct attribute *default_attrs[] = {
133 ref_physical_package_id_attr 111 &attr_physical_package_id.attr,
134 ref_core_id_attr 112 &attr_core_id.attr,
135 ref_thread_siblings_attr 113 &attr_thread_siblings.attr,
136 ref_core_siblings_attr 114 &attr_thread_siblings_list.attr,
115 &attr_core_siblings.attr,
116 &attr_core_siblings_list.attr,
137 NULL 117 NULL
138}; 118};
139 119
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 24f3d2282e11..2158fc0d5a56 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -179,4 +179,17 @@ void arch_update_cpu_topology(void);
179#endif 179#endif
180#endif /* CONFIG_NUMA */ 180#endif /* CONFIG_NUMA */
181 181
182#ifndef topology_physical_package_id
183#define topology_physical_package_id(cpu) ((void)(cpu), -1)
184#endif
185#ifndef topology_core_id
186#define topology_core_id(cpu) ((void)(cpu), 0)
187#endif
188#ifndef topology_thread_siblings
189#define topology_thread_siblings(cpu) cpumask_of_cpu(cpu)
190#endif
191#ifndef topology_core_siblings
192#define topology_core_siblings(cpu) cpumask_of_cpu(cpu)
193#endif
194
182#endif /* _LINUX_TOPOLOGY_H */ 195#endif /* _LINUX_TOPOLOGY_H */