* [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap
2020-06-29 10:37 [PATCH 0/3] Implement shared_cpu_list for powerpc Srikar Dronamraju
@ 2020-06-29 10:37 ` Srikar Dronamraju
2020-06-29 13:26 ` Tejun Heo
2020-06-29 10:37 ` [PATCH 2/3] powerpc/cacheinfo: Make cpumap_show code reusable Srikar Dronamraju
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Srikar Dronamraju @ 2020-06-29 10:37 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Nathan Lynch, Tejun Heo, linuxppc-dev, Srikar Dronamraju
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
#
Cc: Nathan Lynch <nathanl@linux.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
arch/powerpc/kernel/cacheinfo.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index 470336277c67..0d3c45e2fccd 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -652,7 +652,7 @@ static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *att
struct 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 =
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap
2020-06-29 10:37 ` [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap Srikar Dronamraju
@ 2020-06-29 13:26 ` Tejun Heo
0 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2020-06-29 13:26 UTC (permalink / raw)
To: Srikar Dronamraju; +Cc: Nathan Lynch, linuxppc-dev
On Mon, Jun 29, 2020 at 04:07:01PM +0530, Srikar Dronamraju wrote:
> 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
> #
>
> Cc: Nathan Lynch <nathanl@linux.ibm.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] powerpc/cacheinfo: Make cpumap_show code reusable
2020-06-29 10:37 [PATCH 0/3] Implement shared_cpu_list for powerpc Srikar Dronamraju
2020-06-29 10:37 ` [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap Srikar Dronamraju
@ 2020-06-29 10:37 ` Srikar Dronamraju
2020-06-29 10:37 ` [PATCH 3/3] powerpc/cacheinfo: Add per cpu per index shared_cpu_list Srikar Dronamraju
2020-07-16 12:56 ` [PATCH 0/3] Implement shared_cpu_list for powerpc Michael Ellerman
3 siblings, 0 replies; 6+ messages in thread
From: Srikar Dronamraju @ 2020-06-29 10:37 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Nathan Lynch, linuxppc-dev, Srikar Dronamraju
In anticipation of implementing shared_cpu_list, move code under
shared_cpu_map_show to a common function.
No functional changes.
Cc: Nathan Lynch <nathanl@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
arch/powerpc/kernel/cacheinfo.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index 0d3c45e2fccd..5be870f99623 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -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 =
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] powerpc/cacheinfo: Add per cpu per index shared_cpu_list
2020-06-29 10:37 [PATCH 0/3] Implement shared_cpu_list for powerpc Srikar Dronamraju
2020-06-29 10:37 ` [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap Srikar Dronamraju
2020-06-29 10:37 ` [PATCH 2/3] powerpc/cacheinfo: Make cpumap_show code reusable Srikar Dronamraju
@ 2020-06-29 10:37 ` Srikar Dronamraju
2020-07-16 12:56 ` [PATCH 0/3] Implement shared_cpu_list for powerpc Michael Ellerman
3 siblings, 0 replies; 6+ messages in thread
From: Srikar Dronamraju @ 2020-06-29 10:37 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Nathan Lynch, linuxppc-dev, Srikar Dronamraju
Unlike 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
#
Cc: Nathan Lynch <nathanl@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
arch/powerpc/kernel/cacheinfo.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index 5be870f99623..d8d4552af30a 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -670,12 +670,20 @@ show_shared_cpumap(struct kobject *k, struct kobj_attribute *attr, char *buf, bo
static 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,
};
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/3] Implement shared_cpu_list for powerpc
2020-06-29 10:37 [PATCH 0/3] Implement shared_cpu_list for powerpc Srikar Dronamraju
` (2 preceding siblings ...)
2020-06-29 10:37 ` [PATCH 3/3] powerpc/cacheinfo: Add per cpu per index shared_cpu_list Srikar Dronamraju
@ 2020-07-16 12:56 ` Michael Ellerman
3 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2020-07-16 12:56 UTC (permalink / raw)
To: Michael Ellerman, Srikar Dronamraju; +Cc: Nathan Lynch, linuxppc-dev
On Mon, 29 Jun 2020 16:07:00 +0530, Srikar Dronamraju wrote:
> 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
>
> [...]
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
^ permalink raw reply [flat|nested] 6+ messages in thread