From nobody Mon Jun 8 05:27:35 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 1EC8E2EB87F; Tue, 2 Jun 2026 19:30:25 +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=1780428626; cv=none; b=DcKGGzh6avBW8CD25D0s+n0WLHxBLdlU3/ptURYW0Jih9i+S7ng+iFAubBI2yBsGCzQJ3CFslsbmFIWUEA7edUFxWPHffcj7rvMqf6bmimBLTikPiMi5vu+VuuEp+lIinnTU4vIReARao1ulJjXw3qI28+IwAC23VQtutfXCfXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780428626; c=relaxed/simple; bh=T/hwXkUmC/qywRk0gFn8Babtvb1LznyoiszgfHHhzLM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=N6xZ4MB8g+0WvxSXYVashgnMwdEnqMqGnwtve7jSbNzfDGAdnyqM89wGUuSeLrZ6zpeaBo1Xg5PPzxZgQuZu/rkrDFlg/Si2Lt7XhEIcTgvPtzfRWwuVkj+mNgmi3ALnvOYRErLqiE7mn7sJB0irug3mqbMEegnOAcBT/9w7w9I= 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=poZgB/f4; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6+xdV53H; 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="poZgB/f4"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6+xdV53H" Date: Tue, 02 Jun 2026 19:30:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780428623; 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=ZZPunqMO9BLPLfAbPnNLhGanYuGhXNGNtRQkqDed1+I=; b=poZgB/f4wDN519vFmNlBV1JR7scxj1wu9ZWt0WPjP6uFrJy9O1wT5FAtrVI/KLEb51ZWVT mQ1G50+nIIEGyJ/UF8juU82zY5b+rwaZm50cYgRkHo0zpm4mGK3g45CrYWkQ/3y9h8xzgC EX1PBowXTOxzK9wsNeakU6ze1oG/pteuVuhZAt+w9+eqljymHaOrUH8v5q8zkKz8HLN4dT YSvfTp+xtKXY2ThpcBanDA8FTBixZ8z2uW6LOUB3XMJHllc9dwFiTJ/FRW6Mja+djTDkcw o1cglgoce04ratMDz/BNMppWTZTDIFvGMBlE472KjWSoPTCN2NILaqEvCA8WhA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780428623; 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=ZZPunqMO9BLPLfAbPnNLhGanYuGhXNGNtRQkqDed1+I=; b=6+xdV53HJyfdRqCFzm85Kf1qrllgT7OkPg4W3BxHexUgtyF7F0g8U67PoJ/Z1QSjA9rtia YOOmShBhNmcu4sBw== 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/idle: Handle offlining first in idle loop Cc: Frederic Weisbecker , Thomas Gleixner , Shrikanth Hegde , "Rafael J. Wysocki (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260508131647.43868-3-frederic@kernel.org> References: <20260508131647.43868-3-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: <178042862249.710.18003393719146053943.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: 0236aaf07b406100c8c3a6b78dba211f32449f49 Gitweb: https://git.kernel.org/tip/0236aaf07b406100c8c3a6b78dba211f3= 2449f49 Author: Frederic Weisbecker AuthorDate: Fri, 08 May 2026 15:16:34 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 02 Jun 2026 21:27:25 +02:00 sched/idle: Handle offlining first in idle loop Offline handling happens from within the inner idle loop, after the beginning of dyntick cputime accounting, nohz idle load balancing and TIF_NEED_RESCHED polling. This is not necessary and even buggy because: * There is no dyntick handling to do. And calling tick_nohz_idle_enter() messes up with the struct tick_sched reset that was performed on tick_sched_timer_dying(). * There is no nohz idle balancing to do. * Polling on TIF_RESCHED is irrelevant at this stage, there are no more tasks allowed to run. * No need to check if need_resched() before offline handling since stop_machine is done and all per-cpu kthread should be done with their job. Therefore move the offline handling at the beginning of the idle loop. This will also ease the idle cputime unification later by not elapsing idle time while offline through the call to: tick_nohz_idle_enter() -> tick_nohz_start_idle() Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Tested-by: Shrikanth Hegde Reviewed-by: Rafael J. Wysocki (Intel) Reviewed-by: Shrikanth Hegde Link: https://patch.msgid.link/20260508131647.43868-3-frederic@kernel.org --- kernel/sched/idle.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index a83be0c..aa7e3dc 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -280,6 +280,14 @@ static void do_idle(void) int cpu =3D smp_processor_id(); bool got_tick =3D false; =20 + if (cpu_is_offline(cpu)) { + local_irq_disable(); + /* All per-CPU kernel threads should be done by now. */ + WARN_ON_ONCE(need_resched()); + cpuhp_report_idle_dead(); + arch_cpu_idle_dead(); + } + /* * Check if we need to update blocked load */ @@ -331,11 +339,6 @@ static void do_idle(void) */ local_irq_disable(); =20 - if (cpu_is_offline(cpu)) { - cpuhp_report_idle_dead(); - arch_cpu_idle_dead(); - } - arch_cpu_idle_enter(); rcu_nocb_flush_deferred_wakeup(); =20