Implement shared_cpu_list for powerpc
cover Implement shared_cpu_list for powerpc
shared_cpu_list sysfs file is missing in powerpc and shared_cpu_map gives an extra newline character.
Before this patchset
# ls /sys/devices/system/cpu0/cache/index1 coherency_line_size number_of_sets size ways_of_associativity level shared_cpu_map type # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff
#
(Notice the extra blank line).
After this patchset
# ls /sys/devices/system/cpu0/cache/index1 coherency_line_size number_of_sets shared_cpu_map type level shared_cpu_list size ways_of_associativity # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_list 0-7 #
Srikar Dronamraju (3):
powerpc/cacheinfo: Use cpumap_print to print cpumap powerpc/cacheinfo: Make cpumap_show code reusable powerpc/cacheinfo: Add per cpu per index shared_cpu_list
arch/powerpc/kernel/cacheinfo.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 powerpc/cacheinfo: Use cpumap_print to print cpumap
Tejun Heo had modified shared_cpu_map_show to use scnprintf instead of cpumap_print during support for *pb[l] format.
Refer commit 0c118b7bd09a ("powerpc: use %*pb[l] to print bitmaps including cpumasks and nodemasks")
cpumap_print_to_pagebuf is a standard function to print cpumap. With commit 9cf79d115f0d ("bitmap: remove explicit newline handling using scnprintf format string"), there is no need to print explicit newline and trailing null character. cpumap_print_to_pagebuf internally uses scnprintf. Hence replace scnprintf with cpumap_print_to_pagebuf.
Note: shared_cpu_map_show in drivers/base/cacheinfo.c already uses cpumap_print_to_pagebuf.
Before this patch
# cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff
#
(Notice the extra blank line).
After this patch
# cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff #
--- arch/powerpc/kernel/cacheinfo.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/kernel/cacheinfo.c +2 -6
@@ -652,7 +652,7 @@ static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *attstruct cache_index_dir *index;struct cache *cache;const struct cpumask *mask; -int ret, cpu; +int cpu; index =kobj_to_cache_index_dir (k); cache = index->cache;
@@ -664,11 +664,7 @@ static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *att mask = &cache->shared_cpu_map; } - ret =scnprintf (buf,PAGE_SIZE -1 ,"%*pb\n" , -cpumask_pr_args (mask)); - buf[ret++] ='\n' ; - buf[ret] ='\0' ; -return ret; +return cpumap_print_to_pagebuf (false, buf, mask); } static struct kobj_attribute cache_shared_cpu_map_attr =
Signature · 1 line
2.17.1
Re: [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap
Quoted 26 lines · Srikar Dronamraju
Tejun Heo had modified
shared_cpu_map_showto use scnprintf instead ofcpumap_printduring support for *pb[l] format.
Refer commit0c118b7bd09a("powerpc: use %*pb[l] to print bitmaps including cpumasks and nodemasks")
cpumap_print_to_pagebufis a standard function to print cpumap. With commit9cf79d115f0d("bitmap: remove explicit newline handling using scnprintf format string"), there is no need to print explicit newline and trailing null character.cpumap_print_to_pagebufinternally uses scnprintf. Hence replace scnprintf withcpumap_print_to_pagebuf.Note:
shared_cpu_map_showindrivers/base/cacheinfo.calready usescpumap_print_to_pagebuf.Before this patch
# cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff#
(Notice the extra blank line).After this patch
# cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff #
Quoted 5 lines
Cc Nathan Lynch <[email protected]>Cc Tejun Heo <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by Srikar Dronamraju <[email protected]>
Thanks.
Signature · 1 line
tejun
PATCH 2/3 powerpc/cacheinfo: Make cpumap_show code reusable
In reply to Srikar DronamrajuIn anticipation of implementing shared_cpu_list, move code under shared_cpu_map_show to a common function.
No functional changes.
--- arch/powerpc/kernel/cacheinfo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/kernel/cacheinfo.c +8 -2
@@ -647,7 +647,8 @@ static const struct cpumask *get_big_core_shared_cpu_map(int cpu, struct cache *return &cache->shared_cpu_map; } -static ssize_t shared_cpu_map_show (struct kobject *k,struct kobj_attribute *attr,char *buf) +static ssize_t +show_shared_cpumap (struct kobject *k,struct kobj_attribute *attr,char *buf,bool list) {struct cache_index_dir *index;struct cache *cache;
@@ -664,7 +665,12 @@ static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *att mask = &cache->shared_cpu_map; } -return cpumap_print_to_pagebuf (false, buf, mask); +return cpumap_print_to_pagebuf (list, buf, mask); +} + +static ssize_t shared_cpu_map_show (struct kobject *k,struct kobj_attribute *attr,char *buf) +{ + return show_shared_cpumap(k, attr, buf, false) } static struct kobj_attribute cache_shared_cpu_map_attr =
Signature · 1 line
2.17.1
PATCH 3/3 powerpc/cacheinfo: Add per cpu per index shared_cpu_list
In reply to Srikar DronamrajuUnlike drivers/base/cacheinfo, powerpc cacheinfo code is not exposing shared_cpu_list under /sys/devices/system/cpu/cpu<n>/cache/index<m>
Add shared_cpu_list to per cpu per index directory to maintain parity with x86. Some scripts (example: mmtests
https://github.com/gormanm/mmtests) seem to be looking for shared_cpu_list instead of shared_cpu_map.
Before this patch
# ls /sys/devices/system/cpu0/cache/index1 coherency_line_size number_of_sets size ways_of_associativity level shared_cpu_map type # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff #
After this patch
# ls /sys/devices/system/cpu0/cache/index1 coherency_line_size number_of_sets shared_cpu_map type level shared_cpu_list size ways_of_associativity # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_list 0-7 #
--- arch/powerpc/kernel/cacheinfo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/kernel/cacheinfo.c +10 -1
@@ -670,12 +670,20 @@ show_shared_cpumap(struct kobject *k, struct kobj_attribute *attr, char *buf, bostatic ssize_t shared_cpu_map_show (struct kobject *k,struct kobj_attribute *attr,char *buf) { - return show_shared_cpumap(k, attr, buf, false) +return show_shared_cpumap (k, attr, buf, false); +} + +static ssize_t shared_cpu_list_show (struct kobject *k,struct kobj_attribute *attr,char *buf) +{ +return show_shared_cpumap (k, attr, buf, true); }static struct kobj_attribute cache_shared_cpu_map_attr =__ATTR (shared_cpu_map,0444 , shared_cpu_map_show,NULL ); +static struct kobj_attribute cache_shared_cpu_list_attr = +__ATTR (shared_cpu_list,0444 , shared_cpu_list_show,NULL ); +/* Attributes which should always be created -- the kobject/sysfs core * does this automatically via kobj_type->default_attrs. This is the * minimum data required to uniquely identify a cache.
@@ -684,6 +692,7 @@ static struct attribute *cache_index_default_attrs[] = { &cache_type_attr.attr, &cache_level_attr.attr, &cache_shared_cpu_map_attr.attr, + &cache_shared_cpu_list_attr.attr, NULL, };
Signature · 1 line
2.17.1
Michael Ellerman
AppliedQuoted 11 lines · Srikar Dronamraju
shared_cpu_listsysfs file is missing in powerpc andshared_cpu_mapgives an extra newline character.Before this patchset
# ls /sys/devices/system/cpu0/cache/index1 coherency_line_size number_of_sets size ways_of_associativity level shared_cpu_map type # cat /sys/devices/system/cpu0/cache/index1/shared_cpu_map 00ff[...]
Applied to powerpc/next.
[1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap
https://git.kernel.org/powerpc/c/5658cf085ba3c3f3c24ac0f7210f0473794df506 [2/3] powerpc/cacheinfo: Make cpumap_show code reusable https://git.kernel.org/powerpc/c/74b7492e417812ea0f5002e210e2ac07a5728d17 [3/3] powerpc/cacheinfo: Add per cpu per index shared_cpu_list https://git.kernel.org/powerpc/c/a87a77cb947cc9fc89f0dad51aeee66a61cc7fc4
cheers