diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2008-06-05 00:47:29 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-13 04:09:46 -0400 |
commit | c50cbb05a05cf1f9ca3592272eff053c847727d8 (patch) | |
tree | e64a380282a16a9a593c07df8d50b729c825ccc0 /drivers/base | |
parent | aab2545fdd6641b76af0ae96456c4ca9d1e50dad (diff) |
cpu topology: always define CPU topology information
This can result in an empty topology directory in sysfs, and requires
in-kernel users to protect all uses with #ifdef - see
<http://marc.info/?l=linux-netdev&m=120639033904472&w=2>.
The documentation of CPU topology specifies what the defaults should be if
only partial information is available from the hardware. So we can
provide these defaults as a fallback.
This patch:
- Adds default definitions of the 4 topology macros to <linux/topology.h>
- Changes drivers/base/topology.c to use the topology macros unconditionally
and to cope with definitions that aren't lvalues
- Updates documentation accordingly
[ From: Andrew Morton <akpm@linux-foundation.org>
- fold now-duplicated code
- fix layout
]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Chandra Seetharaman <sekharan@us.ibm.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Mike Travis <travis@sgi.com>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: John Hawkes <hawkes@sgi.com>
Cc: Zhang, Yanmin <yanmin.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/topology.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index fdf4044d2e74..24d29a9fc25b 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -59,60 +59,42 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf) | |||
59 | static inline ssize_t show_##name(struct sys_device *dev, char *buf) \ | 59 | static inline ssize_t show_##name(struct sys_device *dev, char *buf) \ |
60 | { \ | 60 | { \ |
61 | unsigned int cpu = dev->id; \ | 61 | unsigned int cpu = dev->id; \ |
62 | return show_cpumap(0, &(topology_##name(cpu)), buf); \ | 62 | cpumask_t siblings = topology_##name(cpu); \ |
63 | return show_cpumap(0, &siblings, buf); \ | ||
63 | } | 64 | } |
64 | 65 | ||
65 | #define define_siblings_show_list(name) \ | 66 | #define define_siblings_show_list(name) \ |
66 | static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ | 67 | static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ |
67 | { \ | 68 | { \ |
68 | unsigned int cpu = dev->id; \ | 69 | unsigned int cpu = dev->id; \ |
69 | return show_cpumap(1, &(topology_##name(cpu)), buf); \ | 70 | cpumask_t siblings = topology_##name(cpu); \ |
71 | return show_cpumap(1, &siblings, buf); \ | ||
70 | } | 72 | } |
71 | 73 | ||
72 | #define define_siblings_show_func(name) \ | 74 | #define define_siblings_show_func(name) \ |
73 | define_siblings_show_map(name); define_siblings_show_list(name) | 75 | define_siblings_show_map(name); define_siblings_show_list(name) |
74 | 76 | ||
75 | #ifdef topology_physical_package_id | ||
76 | define_id_show_func(physical_package_id); | 77 | define_id_show_func(physical_package_id); |
77 | define_one_ro(physical_package_id); | 78 | define_one_ro(physical_package_id); |
78 | #define ref_physical_package_id_attr &attr_physical_package_id.attr, | ||
79 | #else | ||
80 | #define ref_physical_package_id_attr | ||
81 | #endif | ||
82 | 79 | ||
83 | #ifdef topology_core_id | ||
84 | define_id_show_func(core_id); | 80 | define_id_show_func(core_id); |
85 | define_one_ro(core_id); | 81 | define_one_ro(core_id); |
86 | #define ref_core_id_attr &attr_core_id.attr, | ||
87 | #else | ||
88 | #define ref_core_id_attr | ||
89 | #endif | ||
90 | 82 | ||
91 | #ifdef topology_thread_siblings | ||
92 | define_siblings_show_func(thread_siblings); | 83 | define_siblings_show_func(thread_siblings); |
93 | define_one_ro(thread_siblings); | 84 | define_one_ro(thread_siblings); |
94 | define_one_ro(thread_siblings_list); | 85 | define_one_ro(thread_siblings_list); |
95 | #define ref_thread_siblings_attr \ | ||
96 | &attr_thread_siblings.attr, &attr_thread_siblings_list.attr, | ||
97 | #else | ||
98 | #define ref_thread_siblings_attr | ||
99 | #endif | ||
100 | 86 | ||
101 | #ifdef topology_core_siblings | ||
102 | define_siblings_show_func(core_siblings); | 87 | define_siblings_show_func(core_siblings); |
103 | define_one_ro(core_siblings); | 88 | define_one_ro(core_siblings); |
104 | define_one_ro(core_siblings_list); | 89 | define_one_ro(core_siblings_list); |
105 | #define ref_core_siblings_attr \ | ||
106 | &attr_core_siblings.attr, &attr_core_siblings_list.attr, | ||
107 | #else | ||
108 | #define ref_core_siblings_attr | ||
109 | #endif | ||
110 | 90 | ||
111 | static struct attribute *default_attrs[] = { | 91 | static struct attribute *default_attrs[] = { |
112 | ref_physical_package_id_attr | 92 | &attr_physical_package_id.attr, |
113 | ref_core_id_attr | 93 | &attr_core_id.attr, |
114 | ref_thread_siblings_attr | 94 | &attr_thread_siblings.attr, |
115 | ref_core_siblings_attr | 95 | &attr_thread_siblings_list.attr, |
96 | &attr_core_siblings.attr, | ||
97 | &attr_core_siblings_list.attr, | ||
116 | NULL | 98 | NULL |
117 | }; | 99 | }; |
118 | 100 | ||