diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2010-08-31 04:28:17 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-09-09 14:41:25 -0400 |
commit | b40d8ed4e42c79f8ed1cf345eed0888f4a2f0678 (patch) | |
tree | e7bfe98c1cbf21a871fee2c25640898c7b60bcfb | |
parent | 01a08546af311c065f34727787dd0cc8dc0c216f (diff) |
topology/sysfs: Provide book id and siblings attributes
Create attributes:
/sys/devices/system/cpu/cpuX/topology/book_id
/sys/devices/system/cpu/cpuX/topology/book_siblings
which show the book id and the book siblings of a cpu.
Unlike the attributes for SMT and MC these attributes are only present if
CONFIG_SCHED_BOOK is set. There is no reason to pollute sysfs for every
architecture with unused attributes.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20100831082844.435648457@de.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | Documentation/cputopology.txt | 23 | ||||
-rw-r--r-- | drivers/base/topology.c | 16 |
2 files changed, 35 insertions, 4 deletions
diff --git a/Documentation/cputopology.txt b/Documentation/cputopology.txt index f1c5c4bccd3e..902d3151f527 100644 --- a/Documentation/cputopology.txt +++ b/Documentation/cputopology.txt | |||
@@ -14,25 +14,39 @@ to /proc/cpuinfo. | |||
14 | identifier (rather than the kernel's). The actual value is | 14 | identifier (rather than the kernel's). The actual value is |
15 | architecture and platform dependent. | 15 | architecture and platform dependent. |
16 | 16 | ||
17 | 3) /sys/devices/system/cpu/cpuX/topology/thread_siblings: | 17 | 3) /sys/devices/system/cpu/cpuX/topology/book_id: |
18 | |||
19 | the book ID of cpuX. Typically it is the hardware platform's | ||
20 | identifier (rather than the kernel's). The actual value is | ||
21 | architecture and platform dependent. | ||
22 | |||
23 | 4) /sys/devices/system/cpu/cpuX/topology/thread_siblings: | ||
18 | 24 | ||
19 | internel kernel map of cpuX's hardware threads within the same | 25 | internel kernel map of cpuX's hardware threads within the same |
20 | core as cpuX | 26 | core as cpuX |
21 | 27 | ||
22 | 4) /sys/devices/system/cpu/cpuX/topology/core_siblings: | 28 | 5) /sys/devices/system/cpu/cpuX/topology/core_siblings: |
23 | 29 | ||
24 | internal kernel map of cpuX's hardware threads within the same | 30 | internal kernel map of cpuX's hardware threads within the same |
25 | physical_package_id. | 31 | physical_package_id. |
26 | 32 | ||
33 | 6) /sys/devices/system/cpu/cpuX/topology/book_siblings: | ||
34 | |||
35 | internal kernel map of cpuX's hardware threads within the same | ||
36 | book_id. | ||
37 | |||
27 | To implement it in an architecture-neutral way, a new source file, | 38 | To implement it in an architecture-neutral way, a new source file, |
28 | drivers/base/topology.c, is to export the 4 attributes. | 39 | drivers/base/topology.c, is to export the 4 or 6 attributes. The two book |
40 | related sysfs files will only be created if CONFIG_SCHED_BOOK is selected. | ||
29 | 41 | ||
30 | For an architecture to support this feature, it must define some of | 42 | For an architecture to support this feature, it must define some of |
31 | these macros in include/asm-XXX/topology.h: | 43 | these macros in include/asm-XXX/topology.h: |
32 | #define topology_physical_package_id(cpu) | 44 | #define topology_physical_package_id(cpu) |
33 | #define topology_core_id(cpu) | 45 | #define topology_core_id(cpu) |
46 | #define topology_book_id(cpu) | ||
34 | #define topology_thread_cpumask(cpu) | 47 | #define topology_thread_cpumask(cpu) |
35 | #define topology_core_cpumask(cpu) | 48 | #define topology_core_cpumask(cpu) |
49 | #define topology_book_cpumask(cpu) | ||
36 | 50 | ||
37 | The type of **_id is int. | 51 | The type of **_id is int. |
38 | The type of siblings is (const) struct cpumask *. | 52 | The type of siblings is (const) struct cpumask *. |
@@ -45,6 +59,9 @@ not defined by include/asm-XXX/topology.h: | |||
45 | 3) thread_siblings: just the given CPU | 59 | 3) thread_siblings: just the given CPU |
46 | 4) core_siblings: just the given CPU | 60 | 4) core_siblings: just the given CPU |
47 | 61 | ||
62 | For architectures that don't support books (CONFIG_SCHED_BOOK) there are no | ||
63 | default definitions for topology_book_id() and topology_book_cpumask(). | ||
64 | |||
48 | Additionally, CPU topology information is provided under | 65 | Additionally, CPU topology information is provided under |
49 | /sys/devices/system/cpu and includes these files. The internal | 66 | /sys/devices/system/cpu and includes these files. The internal |
50 | source for the output is in brackets ("[]"). | 67 | source for the output is in brackets ("[]"). |
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index 9fc630ce1ddb..f6f37a05a0c3 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -45,7 +45,8 @@ static ssize_t show_##name(struct sys_device *dev, \ | |||
45 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ | 45 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ |
46 | } | 46 | } |
47 | 47 | ||
48 | #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) | 48 | #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \ |
49 | defined(topology_book_cpumask) | ||
49 | static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) | 50 | static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) |
50 | { | 51 | { |
51 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; | 52 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; |
@@ -114,6 +115,14 @@ define_siblings_show_func(core_cpumask); | |||
114 | define_one_ro_named(core_siblings, show_core_cpumask); | 115 | define_one_ro_named(core_siblings, show_core_cpumask); |
115 | define_one_ro_named(core_siblings_list, show_core_cpumask_list); | 116 | define_one_ro_named(core_siblings_list, show_core_cpumask_list); |
116 | 117 | ||
118 | #ifdef CONFIG_SCHED_BOOK | ||
119 | define_id_show_func(book_id); | ||
120 | define_one_ro(book_id); | ||
121 | define_siblings_show_func(book_cpumask); | ||
122 | define_one_ro_named(book_siblings, show_book_cpumask); | ||
123 | define_one_ro_named(book_siblings_list, show_book_cpumask_list); | ||
124 | #endif | ||
125 | |||
117 | static struct attribute *default_attrs[] = { | 126 | static struct attribute *default_attrs[] = { |
118 | &attr_physical_package_id.attr, | 127 | &attr_physical_package_id.attr, |
119 | &attr_core_id.attr, | 128 | &attr_core_id.attr, |
@@ -121,6 +130,11 @@ static struct attribute *default_attrs[] = { | |||
121 | &attr_thread_siblings_list.attr, | 130 | &attr_thread_siblings_list.attr, |
122 | &attr_core_siblings.attr, | 131 | &attr_core_siblings.attr, |
123 | &attr_core_siblings_list.attr, | 132 | &attr_core_siblings_list.attr, |
133 | #ifdef CONFIG_SCHED_BOOK | ||
134 | &attr_book_id.attr, | ||
135 | &attr_book_siblings.attr, | ||
136 | &attr_book_siblings_list.attr, | ||
137 | #endif | ||
124 | NULL | 138 | NULL |
125 | }; | 139 | }; |
126 | 140 | ||