[PATCH 0/3] Implement shared_cpu_list for powerpc

STALE2211d

6 messages, 3 authors, 2020-07-16 · open the first message on its own page

[PATCH 0/3] Implement shared_cpu_list for powerpc

From: Srikar Dronamraju <hidden>
Date: 2020-06-29 10:39:05

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(-)

Cc: Nathan Lynch <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
-- 
2.17.1

[PATCH 2/3] powerpc/cacheinfo: Make cpumap_show code reusable

From: Srikar Dronamraju <hidden>
Date: 2020-06-29 10:40:43

In anticipation of implementing shared_cpu_list, move code under
shared_cpu_map_show to a common function.

No functional changes.

Cc: Nathan Lynch <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <redacted>
---
 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

[PATCH 3/3] powerpc/cacheinfo: Add per cpu per index shared_cpu_list

From: Srikar Dronamraju <hidden>
Date: 2020-06-29 10:42:47

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 <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <redacted>
---
 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

[PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap

From: Srikar Dronamraju <hidden>
Date: 2020-06-29 10:44:25

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 <redacted>
Cc: Tejun Heo <tj@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <redacted>
---
 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

Re: [PATCH 1/3] powerpc/cacheinfo: Use cpumap_print to print cpumap

From: Tejun Heo <tj@kernel.org>
Date: 2020-06-29 13:29:41

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 <redacted>
Cc: Tejun Heo <tj@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Srikar Dronamraju <redacted>
Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

Re: [PATCH 0/3] Implement shared_cpu_list for powerpc

From: Michael Ellerman <hidden>
Date: 2020-07-16 14:36:49

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help