From nobody Mon Jun 8 05:26:08 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81ECA33C187; Tue, 2 Jun 2026 19:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780428621; cv=none; b=UOpnviw0LWMi9qRWBDUj47t9C1hqnWzzaMLdt4q2wRMZ3BIl2XLTfxmKs/6KOwe/RobCaKlS2H5y9Qi3XyfHrpD8TcFgyeY3oMW6d/xT5ROLcPAA+ibHW2s5L9YYDUcV4hRax+XAoRtKswWX0L9V6OQ6Q/IcerWECvUgGWPVBdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780428621; c=relaxed/simple; bh=kI5UaKVpB6yGbYhepnndUijfxuxy8HNiMpT2NJTiEHk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=WHSmocN4SOgHPIcZlcSiKfyC168Z8z21Pn5aO5vXKJNJX3fg2pTTgwpIU3dtQlp39ijVA4qCN6ShKz6ysdD1Gzs2rS/e5Yc/UN95tWfx6rkk1736kHT/yyvZt4XBROj9wCStYjv8YDHjkOZSn+NpZtzflWHJEOs3PXRFferF3Yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=v2KAsvay; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5qf3b/iQ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="v2KAsvay"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5qf3b/iQ" Date: Tue, 02 Jun 2026 19:30:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780428618; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0gtio08/jiXgGj7u9E9uFgN5iRVHcV8pWbn/pFNBEo=; b=v2KAsvaym+Mg6h6JfGGZ7O5LyGP9XkRvxvyVGtIW5bqhUTtFY5IjESJvYvpd26kgGXQXzt JsNvhk5bbygnua15ydJaerruEBHxJ8UDKC2wHbapE9CdUoPXa3OFEL4/6jdvlT0Kwztm7W VWXSYETKeWvfhKxT06ilhxhThNOiqmtIvjbkDsP2qlF/QDSDvLRymBjSh40s2hmGU+YKz6 OSxIZmGCcp/KgnGo0LvNxQFQFPixzV4jz1kGfnDcaHR/yjGsswBkjofSiWEQTT7vE2qKig vg9P2756yihgpPD6Xn6aKUvwrg5GG63WCB6KsvpL+LJM900OVU1Nk8Ae+AHJCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780428618; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0gtio08/jiXgGj7u9E9uFgN5iRVHcV8pWbn/pFNBEo=; b=5qf3b/iQFY9eusOOPyENUY0288UMhU9yDw023PjUG9UHJw0uNFtv4U+s9sRViKYUaJpl0c z6VJQZySuYyGXNCw== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/nohz] s390/time: Prepare to stop elapsing in dynticks-idle Cc: Heiko Carstens , Frederic Weisbecker , Thomas Gleixner , Shrikanth Hegde , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260508131647.43868-7-frederic@kernel.org> References: <20260508131647.43868-7-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178042861650.710.16254160337748670913.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/nohz branch of tip: Commit-ID: ad5a9e14ec8b4a868fea13a9dfa1fb38b2c35354 Gitweb: https://git.kernel.org/tip/ad5a9e14ec8b4a868fea13a9dfa1fb38b= 2c35354 Author: Frederic Weisbecker AuthorDate: Fri, 08 May 2026 15:16:38 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 02 Jun 2026 21:27:25 +02:00 s390/time: Prepare to stop elapsing in dynticks-idle Currently the tick subsystem stores the idle cputime accounting in private fields, allowing cohabitation with architecture idle vtime accounting. The former is fetched on online CPUs, the latter on offline CPUs. For consolidation purposes, architecture vtime accounting will continue to account the cputime but will make a break when the idle tick is stopped. The dyntick cputime accounting will then be relayed by the tick subsystem so that the idle cputime is still seen advancing coherently even when the tick isn't there to flush the idle vtime. Prepare for that and introduce three new APIs which will be used in subsequent patches: - vtime_dynticks_start() is deemed to be called when idle enters in dyntick mode. The idle cputime that elapsed so far is accumulated and accounted. Also idle time accounting is ignored. - vtime_dynticks_stop() is deemed to be called when idle exits from dyntick mode. The vtime entry clocks are fast-forward to current time so that idle accounting restarts elapsing from now. Also idle time accounting is resumed. - vtime_reset() is deemed to be called from dynticks idle IRQ entry to fast-forward the clock to current time so that the IRQ time is still accounted by vtime while nohz cputime is paused. Also accumulated vtime won't be flushed from dyntick-idle ticks to avoid accounting twice the idle cputime, along with nohz accounting. Co-developed-by: Heiko Carstens Signed-off-by: Heiko Carstens Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Tested-by: Shrikanth Hegde Link: https://patch.msgid.link/20260508131647.43868-7-frederic@kernel.org --- arch/s390/include/asm/idle.h | 2 +- arch/s390/kernel/idle.c | 5 +- arch/s390/kernel/vtime.c | 75 +++++++++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h index 32536ee..e4ad09a 100644 --- a/arch/s390/include/asm/idle.h +++ b/arch/s390/include/asm/idle.h @@ -8,10 +8,12 @@ #ifndef _S390_IDLE_H #define _S390_IDLE_H =20 +#include #include #include =20 struct s390_idle_data { + bool idle_dyntick; unsigned long idle_count; unsigned long idle_time; unsigned long clock_idle_enter; diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c index 1f1b06b..4685d7c 100644 --- a/arch/s390/kernel/idle.c +++ b/arch/s390/kernel/idle.c @@ -31,7 +31,10 @@ void account_idle_time_irq(void) /* Account time spent with enabled wait psw loaded as idle time. */ __atomic64_add(idle_time, &idle->idle_time); __atomic64_add_const(1, &idle->idle_count); - account_idle_time(cputime_to_nsecs(idle_time)); + + /* Dyntick idle time accounted by nohz/scheduler */ + if (!idle->idle_dyntick) + account_idle_time(cputime_to_nsecs(idle_time)); } =20 void noinstr arch_cpu_idle(void) diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index bf48744..d1102a6 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -17,6 +17,7 @@ #include #include #include +#include #include =20 #include "entry.h" @@ -110,6 +111,16 @@ static void account_system_index_scaled(struct task_st= ruct *p, u64 cputime, account_system_index_time(p, cputime_to_nsecs(cputime), index); } =20 +static inline void vtime_reset_last_update(struct lowcore *lc) +{ + asm volatile( + " stpt %0\n" /* Store current cpu timer value */ + " stckf %1" /* Store current tod clock value */ + : "=3DQ" (lc->last_update_timer), + "=3DQ" (lc->last_update_clock) + : : "cc"); +} + /* * Update process times based on virtual cpu times stored by entry.S * to the lowcore fields user_timer, system_timer & steal_clock. @@ -121,17 +132,16 @@ static int do_account_vtime(struct task_struct *tsk) =20 timer =3D lc->last_update_timer; clock =3D lc->last_update_clock; - asm volatile( - " stpt %0\n" /* Store current cpu timer value */ - " stckf %1" /* Store current tod clock value */ - : "=3DQ" (lc->last_update_timer), - "=3DQ" (lc->last_update_clock) - : : "cc"); + + vtime_reset_last_update(lc); + clock =3D lc->last_update_clock - clock; timer -=3D lc->last_update_timer; =20 if (hardirq_count()) lc->hardirq_timer +=3D timer; + else if (in_serving_softirq()) + lc->softirq_timer +=3D timer; else lc->system_timer +=3D timer; =20 @@ -231,13 +241,62 @@ EXPORT_SYMBOL_GPL(vtime_account_kernel); =20 void vtime_account_softirq(struct task_struct *tsk) { - get_lowcore()->softirq_timer +=3D vtime_delta(); + if (!__this_cpu_read(s390_idle.idle_dyntick)) + get_lowcore()->softirq_timer +=3D vtime_delta(); + else + vtime_flush(tsk); } =20 void vtime_account_hardirq(struct task_struct *tsk) { - get_lowcore()->hardirq_timer +=3D vtime_delta(); + if (!__this_cpu_read(s390_idle.idle_dyntick)) { + get_lowcore()->hardirq_timer +=3D vtime_delta(); + } else { + /* + * In dynticks mode, the idle cputime is accounted by the nohz + * subsystem. Therefore the s390 timer/clocks are reset on IRQ + * entry and steal time must be accounted now. + */ + vtime_flush(tsk); + } +} + +#ifdef CONFIG_NO_HZ_COMMON +/** + * vtime_reset - Fast forward vtime entry clocks + * + * Called from dynticks idle IRQ entry to fast-forward the clocks to curre= nt time + * so that the IRQ time is still accounted by vtime while nohz cputime is = paused. + */ +void vtime_reset(void) +{ + vtime_reset_last_update(get_lowcore()); +} + +/** + * vtime_dyntick_start - Inform vtime about entry to idle-dynticks + * + * Called when idle enters in dyntick mode. The idle cputime that elapsed = so far + * is flushed and the tick subsystem takes over the idle cputime accountin= g. + */ +void vtime_dyntick_start(void) +{ + __this_cpu_write(s390_idle.idle_dyntick, true); + vtime_flush(current); +} + +/** + * vtime_dyntick_stop - Inform vtime about exit from idle-dynticks + * + * Called when idle exits from dyntick mode. The vtime entry clocks are + * fast-forward to current time and idle accounting resumes. + */ +void vtime_dyntick_stop(void) +{ + vtime_reset_last_update(get_lowcore()); + __this_cpu_write(s390_idle.idle_dyntick, false); } +#endif /* CONFIG_NO_HZ_COMMON */ =20 /* * Sorted add to a list. List is linear searched until first bigger