[RFC PATCH 1/3] fixup! s390/time: Prepare to stop elapsing in dynticks-idle

Heiko Carstens posted 3 patches 1 month, 1 week ago
[RFC PATCH 1/3] fixup! s390/time: Prepare to stop elapsing in dynticks-idle
Posted by Heiko Carstens 1 month, 1 week ago
This should be merged with "s390/time: Prepare to stop elapsing in
dynticks-idle".

It makes sure that idle->clock_idle_enter is always set when loading the
idle psw. Otherwise the idle_time calculation in account_idle_time_irq()
would be incorrect.

Also "revert" some not needed code movements and whitespace changes to keep
the diff minimal.

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

diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h
index 285b3da318d6..7f2a1240b6ff 100644
--- a/arch/s390/include/asm/idle.h
+++ b/arch/s390/include/asm/idle.h
@@ -13,12 +13,12 @@
 #include <linux/device.h>
 
 struct s390_idle_data {
-	bool		idle_dyntick;
-	unsigned long	idle_count;
-	unsigned long	idle_time;
-	unsigned long	clock_idle_enter;
-	unsigned long	timer_idle_enter;
-	unsigned long	mt_cycles_enter[8];
+	bool	      idle_dyntick;
+	unsigned long idle_count;
+	unsigned long idle_time;
+	unsigned long clock_idle_enter;
+	unsigned long timer_idle_enter;
+	unsigned long mt_cycles_enter[8];
 };
 
 DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index 614db5ea6ea3..fb4f431342f5 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -35,11 +35,10 @@ void account_idle_time_irq(void)
 			this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
 	}
 
-	WRITE_ONCE(idle->idle_count, READ_ONCE(idle->idle_count) + 1);
-
 	/* Account time spent with enabled wait psw loaded as idle time. */
 	idle_time = lc->int_clock - idle->clock_idle_enter;
 	WRITE_ONCE(idle->idle_time, READ_ONCE(idle->idle_time) + idle_time);
+	WRITE_ONCE(idle->idle_count, READ_ONCE(idle->idle_count) + 1);
 
 	/* Dyntick idle time accounted by nohz/scheduler */
 	if (idle->idle_dyntick)
@@ -66,10 +65,8 @@ void noinstr arch_cpu_idle(void)
 	set_cpu_flag(CIF_ENABLED_WAIT);
 	if (smp_cpu_mtid)
 		stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter);
-	if (!idle->idle_dyntick) {
-		idle->clock_idle_enter = get_tod_clock_fast();
-		idle->timer_idle_enter = get_cpu_timer();
-	}
+	idle->clock_idle_enter = get_tod_clock_fast();
+	idle->timer_idle_enter = get_cpu_timer();
 	bpon();
 	__load_psw_mask(psw_mask);
 }
-- 
2.51.0
Re: [RFC PATCH 1/3] fixup! s390/time: Prepare to stop elapsing in dynticks-idle
Posted by Frederic Weisbecker 3 weeks, 5 days ago
Le Wed, Feb 25, 2026 at 03:51:44PM +0100, Heiko Carstens a écrit :
> This should be merged with "s390/time: Prepare to stop elapsing in
> dynticks-idle".
> 
> It makes sure that idle->clock_idle_enter is always set when loading the
> idle psw. Otherwise the idle_time calculation in account_idle_time_irq()
> would be incorrect.
> 
> Also "revert" some not needed code movements and whitespace changes to keep
> the diff minimal.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

Thank you, I'm folding this to the patch.

-- 
Frederic Weisbecker
SUSE Labs