From nobody Mon Jun 8 05:26:23 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 958281B87C0; Tue, 2 Jun 2026 19:30:07 +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=1780428609; cv=none; b=O6TTk1A2ftedbgK/Qxf/k1uTTpTCgcwQTPYfSeokbI4TqB/TtgfvGzdPlr1i2QCJvhRk9i8ZnIIUZlPXb5RvagsEjKTSWPdQGP3qmH44NB9H6tXVZf7soMbO0wkbi4dd4OWR2Kxz1QZzpkXeUs/47XJzxGWjDiLwicGGacS68ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780428609; c=relaxed/simple; bh=HcMrhd6/v+yxhNivCfhg11vvvJMAF9T1xUhwzkMolVo=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=kfVcxhJRDfY0HXUDj5UsgL3IJ1VmUs8PI+R/HW1Tq8ylPEivRyrh6qaWRypry6HhHfTwpJ/Btnym2eRHajoOuCwMOk57RVrTVzFXYObdyZuje5VqX9I6XjZW584czy6WusvkykNL8hcT8/f/t1lBWK/bH2cekONa1/12b3aRU9g= 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=giDI9/mf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=htRlpV6m; 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="giDI9/mf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="htRlpV6m" Date: Tue, 02 Jun 2026 19:30:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780428606; 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=UyX9m1Xped+XaDr/EOIAA+QXWRWU9agU0SPjlXE/5F8=; b=giDI9/mffzfDGSzX1Z6t7zMWNv0devJZtEtner0NLMUEA4Npok9fLujKklruUG5G+N4kic 5xPbm1c4GgA8QrLnpa5r1xzfDs7FSpgk9VxTC2+c1BDwEPq3BsrlyuEUBEPNmO28yOLw1n 6AhZdhP4o/uKzEdtelaYPS9XlDcQNxfbtHe2rbcuSa1XIkLgIq0/OW9Ehp+NoHQjEF0GPc HEDoDtel83ZQUDBzUzc5uV3mfCmICOCf8YJVWeHzt3OCIcU7w2zIg0zbLYrh3feYCGB8s9 F6SbxCm0WzR793r6r/xZjgEsoDsrvXJA+kwXRB26Pt5XrCKtPKR3ja+n1pEpqg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780428606; 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=UyX9m1Xped+XaDr/EOIAA+QXWRWU9agU0SPjlXE/5F8=; b=htRlpV6mWtIhhpxY+8FLBVpFQrYAfVIQv+wllu/3KFt7UFSKklI+oF/BgSGD0ROgvm9+1b 9pyOsWOzLweHFoCg== 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] sched/cputime: Handle idle irqtime gracefully Cc: Frederic Weisbecker , Thomas Gleixner , Shrikanth Hegde , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260508131647.43868-15-frederic@kernel.org> References: <20260508131647.43868-15-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: <178042860468.710.15163507606999760962.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: 7198e3927a14535475a24cce559f41f97e6c0b66 Gitweb: https://git.kernel.org/tip/7198e3927a14535475a24cce559f41f97= e6c0b66 Author: Frederic Weisbecker AuthorDate: Fri, 08 May 2026 15:16:46 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 02 Jun 2026 21:27:26 +02:00 sched/cputime: Handle idle irqtime gracefully The dyntick-idle cputime accounting always assumes that interrupt time accounting is enabled and consequently stops elapsing the idle time during dyntick-idle interrupts. This doesn't mix up well with disabled interrupt time accounting because then idle interrupts become a cputime blind-spot. Also this feature is disabled on most configurations and the overhead of pausing dyntick-idle accounting while in idle interrupts could then be avoided. Fix the situation with conditionally pausing dyntick-idle accounting during idle interrupts only iff either native vtime (which does interrupt time accounting) or generic interrupt time accounting are enabled. Also make sure that the accumulated interrupt time is not accidentally substracted from later accounting. Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Tested-by: Shrikanth Hegde Link: https://patch.msgid.link/20260508131647.43868-15-frederic@kernel.org --- kernel/sched/cputime.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 335d2c1..94be22a 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -47,7 +47,8 @@ static void irqtime_account_delta(struct irqtime *irqtime= , u64 delta, u64_stats_update_begin(&irqtime->sync); cpustat[idx] +=3D delta; irqtime->total +=3D delta; - irqtime->tick_delta +=3D delta; + if (!kcpustat_idle_dyntick()) + irqtime->tick_delta +=3D delta; u64_stats_update_end(&irqtime->sync); } =20 @@ -444,6 +445,10 @@ static void kcpustat_idle_stop(struct kernel_cpustat *= kc, u64 now) =20 static void kcpustat_idle_start(struct kernel_cpustat *kc, u64 now) { + /* Irqtime accounting might have been enabled in the middle of the IRQ */ + if (kc->idle_elapse) + return; + write_seqcount_begin(&kc->idle_sleeptime_seq); kc->idle_entrytime =3D now; kc->idle_elapse =3D true; @@ -478,7 +483,8 @@ void kcpustat_irq_enter(u64 now) { struct kernel_cpustat *kc =3D kcpustat_this_cpu; =20 - if (!vtime_generic_enabled_this_cpu()) + if (!vtime_generic_enabled_this_cpu() && + (irqtime_enabled() || vtime_accounting_enabled_this_cpu())) kcpustat_idle_stop(kc, now); } =20 @@ -486,7 +492,15 @@ void kcpustat_irq_exit(u64 now) { struct kernel_cpustat *kc =3D kcpustat_this_cpu; =20 - if (!vtime_generic_enabled_this_cpu()) + /* + * Generic vtime already does its own idle accounting. + * But irqtime accounting or arch vtime which also accounts IRQs + * need to pause nohz accounting. Resume nohz accounting as long + * as the irqtime config is enabled to handle case where irqtime + * accounting got runtime disabled in the middle of an IRQ. + */ + if (!vtime_generic_enabled_this_cpu() && + (IS_ENABLED(CONFIG_IRQ_TIME_ACCOUNTING) || vtime_accounting_enabled_t= his_cpu())) kcpustat_idle_start(kc, now); } =20