[RFC PATCH 3/3] s390/idle: Remove idle time and count sysfs files

Heiko Carstens posted 3 patches 1 month, 1 week ago
[RFC PATCH 3/3] s390/idle: Remove idle time and count sysfs files
Posted by Heiko Carstens 1 month, 1 week ago
Remove the s390 specific idle_time_us and idle_count per-cpu sysfs
files. They do not provide an additional value. The risk that there are
existing applications which rely on these architecture specific files
should be very low.

However if it turns out such applications exist, this can be easily
reverted.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/include/asm/idle.h |  4 ----
 arch/s390/kernel/idle.c      | 20 +-------------------
 arch/s390/kernel/smp.c       | 32 +-------------------------------
 3 files changed, 2 insertions(+), 54 deletions(-)

diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h
index dc04d63b6187..f0f3d38ef648 100644
--- a/arch/s390/include/asm/idle.h
+++ b/arch/s390/include/asm/idle.h
@@ -10,7 +10,6 @@
 
 #include <linux/percpu-defs.h>
 #include <linux/types.h>
-#include <linux/device.h>
 #include <asm/tod_types.h>
 
 struct s390_idle_data {
@@ -26,9 +25,6 @@ struct s390_idle_data {
 
 DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
 
-extern struct device_attribute dev_attr_idle_count;
-extern struct device_attribute dev_attr_idle_time_us;
-
 void psw_idle(struct s390_idle_data *data, unsigned long psw_mask);
 
 #endif /* _S390_IDLE_H */
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index ceb95c0d22eb..db120ef810ac 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -81,7 +81,7 @@ static u64 arch_cpu_in_idle_time(int cpu)
 			idle_time = now.tod - idle->clock_idle_enter.tod;
 		smp_mb();
 	} while (__atomic_read(&idle->sequence) != seq);
-	return tod_to_ns(idle_time);
+	return cputime_to_nsecs(idle_time);
 }
 
 static u64 arch_cpu_idle_time(int cpu, enum cpu_usage_stat idx, bool compute_delta)
@@ -133,24 +133,6 @@ void noinstr arch_cpu_idle(void)
 	__load_psw_mask(psw_mask);
 }
 
-static ssize_t show_idle_count(struct device *dev,
-			       struct device_attribute *attr, char *buf)
-{
-	struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
-
-	return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_count));
-}
-DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
-
-static ssize_t show_idle_time(struct device *dev,
-			      struct device_attribute *attr, char *buf)
-{
-	struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
-
-	return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_time) >> 12);
-}
-DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
-
 void arch_cpu_idle_enter(void)
 {
 }
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 439eab2fb67a..64f0a5617e86 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1086,31 +1086,6 @@ static struct attribute_group cpu_common_attr_group = {
 	.attrs = cpu_common_attrs,
 };
 
-static struct attribute *cpu_online_attrs[] = {
-	&dev_attr_idle_count.attr,
-	&dev_attr_idle_time_us.attr,
-	NULL,
-};
-
-static struct attribute_group cpu_online_attr_group = {
-	.attrs = cpu_online_attrs,
-};
-
-static int smp_cpu_online(unsigned int cpu)
-{
-	struct cpu *c = per_cpu_ptr(&cpu_devices, cpu);
-
-	return sysfs_create_group(&c->dev.kobj, &cpu_online_attr_group);
-}
-
-static int smp_cpu_pre_down(unsigned int cpu)
-{
-	struct cpu *c = per_cpu_ptr(&cpu_devices, cpu);
-
-	sysfs_remove_group(&c->dev.kobj, &cpu_online_attr_group);
-	return 0;
-}
-
 bool arch_cpu_is_hotpluggable(int cpu)
 {
 	return !!cpu;
@@ -1176,18 +1151,13 @@ static DEVICE_ATTR_WO(rescan);
 static int __init s390_smp_init(void)
 {
 	struct device *dev_root;
-	int rc;
+	int rc = 0;
 
 	dev_root = bus_get_dev_root(&cpu_subsys);
 	if (dev_root) {
 		rc = device_create_file(dev_root, &dev_attr_rescan);
 		put_device(dev_root);
-		if (rc)
-			return rc;
 	}
-	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online",
-			       smp_cpu_online, smp_cpu_pre_down);
-	rc = rc <= 0 ? rc : 0;
 	return rc;
 }
 subsys_initcall(s390_smp_init);
-- 
2.51.0
Re: [RFC PATCH 3/3] s390/idle: Remove idle time and count sysfs files
Posted by Frederic Weisbecker 3 weeks, 5 days ago
Le Wed, Feb 25, 2026 at 03:51:46PM +0100, Heiko Carstens a écrit :
> Remove the s390 specific idle_time_us and idle_count per-cpu sysfs
> files. They do not provide an additional value. The risk that there are
> existing applications which rely on these architecture specific files
> should be very low.
> 
> However if it turns out such applications exist, this can be easily
> reverted.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

Acked-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs