From: Heiko Carstens <hca@linux.ibm.com>
To: Frederic Weisbecker <frederic@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 5/9] s390/idle: Inline update_timer_idle()
Date: Wed, 18 Feb 2026 15:20:08 +0100 [thread overview]
Message-ID: <20260218142012.863464-6-hca@linux.ibm.com> (raw)
In-Reply-To: <20260218142012.863464-1-hca@linux.ibm.com>
Inline update_timer_idle() again to avoid an extra function call. This
way the generated code is close to old assembler version again.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/idle.h | 3 ++-
arch/s390/include/asm/vtime.h | 34 ++++++++++++++++++++++++++++++++++
arch/s390/kernel/entry.h | 2 --
arch/s390/kernel/idle.c | 34 ++--------------------------------
4 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h
index 133059d9a949..8c5aa7329461 100644
--- a/arch/s390/include/asm/idle.h
+++ b/arch/s390/include/asm/idle.h
@@ -19,10 +19,11 @@ struct s390_idle_data {
unsigned long mt_cycles_enter[8];
};
+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);
-void update_timer_idle(void);
#endif /* _S390_IDLE_H */
diff --git a/arch/s390/include/asm/vtime.h b/arch/s390/include/asm/vtime.h
index 9d25fb35a042..b1db75d14e9d 100644
--- a/arch/s390/include/asm/vtime.h
+++ b/arch/s390/include/asm/vtime.h
@@ -2,6 +2,12 @@
#ifndef _S390_VTIME_H
#define _S390_VTIME_H
+#include <asm/lowcore.h>
+#include <asm/cpu_mf.h>
+#include <asm/idle.h>
+
+DECLARE_PER_CPU(u64, mt_cycles[8]);
+
static inline void update_timer_sys(void)
{
struct lowcore *lc = get_lowcore();
@@ -20,4 +26,32 @@ static inline void update_timer_mcck(void)
lc->last_update_timer = lc->mcck_enter_timer;
}
+static inline void update_timer_idle(void)
+{
+ struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
+ struct lowcore *lc = get_lowcore();
+ u64 cycles_new[8];
+ int i, mtid;
+
+ mtid = smp_cpu_mtid;
+ if (mtid) {
+ stcctm(MT_DIAG, mtid, cycles_new);
+ for (i = 0; i < mtid; i++)
+ __this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
+ }
+ /*
+ * This is a bit subtle: Forward last_update_clock so it excludes idle
+ * time. For correct steal time calculation in do_account_vtime() add
+ * passed wall time before idle_enter to steal_timer:
+ * During the passed wall time before idle_enter CPU time may have
+ * been accounted to system, hardirq, softirq, etc. lowcore fields.
+ * The accounted CPU times will be subtracted again from steal_timer
+ * when accumulated steal time is calculated in do_account_vtime().
+ */
+ lc->steal_timer += idle->clock_idle_enter - lc->last_update_clock;
+ lc->last_update_clock = lc->int_clock;
+ lc->system_timer += lc->last_update_timer - idle->timer_idle_enter;
+ lc->last_update_timer = lc->sys_enter_timer;
+}
+
#endif /* _S390_VTIME_H */
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index dd55cc6bbc28..fb67b4abe68c 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -56,8 +56,6 @@ long sys_s390_pci_mmio_write(unsigned long, const void __user *, size_t);
long sys_s390_pci_mmio_read(unsigned long, void __user *, size_t);
long sys_s390_sthyi(unsigned long function_code, void __user *buffer, u64 __user *return_code, unsigned long flags);
-DECLARE_PER_CPU(u64, mt_cycles[8]);
-
unsigned long stack_alloc(void);
void stack_free(unsigned long stack);
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index 627d82dd900e..1f1b06b6b4ef 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -15,41 +15,11 @@
#include <trace/events/power.h>
#include <asm/cpu_mf.h>
#include <asm/cputime.h>
+#include <asm/idle.h>
#include <asm/nmi.h>
#include <asm/smp.h>
-#include "entry.h"
-static DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
-
-void update_timer_idle(void)
-{
- struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
- struct lowcore *lc = get_lowcore();
- u64 cycles_new[8];
- int i, mtid;
-
- mtid = smp_cpu_mtid;
- if (mtid) {
- stcctm(MT_DIAG, mtid, cycles_new);
- for (i = 0; i < mtid; i++)
- __this_cpu_add(mt_cycles[i], cycles_new[i] - idle->mt_cycles_enter[i]);
- }
-
- /*
- * This is a bit subtle: Forward last_update_clock so it excludes idle
- * time. For correct steal time calculation in do_account_vtime() add
- * passed wall time before idle_enter to steal_timer:
- * During the passed wall time before idle_enter CPU time may have
- * been accounted to system, hardirq, softirq, etc. lowcore fields.
- * The accounted CPU times will be subtracted again from steal_timer
- * when accumulated steal time is calculated in do_account_vtime().
- */
- lc->steal_timer += idle->clock_idle_enter - lc->last_update_clock;
- lc->last_update_clock = lc->int_clock;
-
- lc->system_timer += lc->last_update_timer - idle->timer_idle_enter;
- lc->last_update_timer = lc->sys_enter_timer;
-}
+DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
void account_idle_time_irq(void)
{
--
2.51.0
next prev parent reply other threads:[~2026-02-18 14:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 14:20 [PATCH 0/9] s390/idle/vtime: Minor fixes and cleanups Heiko Carstens
2026-02-18 14:20 ` [PATCH 1/9] s390/idle: Fix cpu idle exit cpu time accounting Heiko Carstens
2026-03-04 14:16 ` Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 2/9] s390/vtime: Fix virtual timer forwarding Heiko Carstens
2026-03-04 14:23 ` Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 3/9] s390/idle: Add comment for non obvious code Heiko Carstens
2026-03-04 14:38 ` Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 4/9] s390/idle: Slightly optimize idle time accounting Heiko Carstens
2026-02-18 14:20 ` Heiko Carstens [this message]
2026-03-04 15:07 ` [PATCH 5/9] s390/idle: Inline update_timer_idle() Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 6/9] s390/irq/idle: Remove psw bits early Heiko Carstens
2026-02-18 14:20 ` [PATCH 7/9] s390/vtime: Use __this_cpu_read() / get rid of READ_ONCE() Heiko Carstens
2026-03-04 14:49 ` Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 8/9] s390/vtime: Use lockdep_assert_irqs_disabled() instead of BUG_ON() Heiko Carstens
2026-03-04 15:08 ` Frederic Weisbecker
2026-02-18 14:20 ` [PATCH 9/9] s390/idle: Remove psw_idle() prototype Heiko Carstens
2026-03-04 15:09 ` Frederic Weisbecker
2026-02-25 9:19 ` [PATCH 0/9] s390/idle/vtime: Minor fixes and cleanups Sven Schnelle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260218142012.863464-6-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frederic@kernel.org \
--cc=gor@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox