From nobody Tue Jun 23 01:16:21 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EE19C433F5 for ; Mon, 14 Mar 2022 09:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238002AbiCNJ3e (ORCPT ); Mon, 14 Mar 2022 05:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237955AbiCNJ31 (ORCPT ); Mon, 14 Mar 2022 05:29:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2033527A; Mon, 14 Mar 2022 02:28:17 -0700 (PDT) Date: Mon, 14 Mar 2022 09:28:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1647250096; 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; bh=N1nMKWa4Wte7sPkoEe/iOaoqC5bC9zSROJdxbx1qa0w=; b=2lCk2c2/zFn9e9E9o39wX8lkdgMH7nb3K+DQbj++Div1a2l4RpgmW6iG8DRh5tDgpm4ZO5 567DAZ1mmNW1gQGPvsYU3WBwA5LJf7qUd+a13+iwvnGSEAO4z2DNZLAUk2V+u3qMDQsKFq Xk4VpnshQiLWPCFmrkvnoV4ySnwQtNp1WXz7iY46Wlni5G2Id5oTk56km2cPFMVoM5R+xl PrvZycjFqLU6PldcyvjsABaWZyFSSdXeRi8XJ5cDnYt1HrzxHHq3N8b2RjYdoHmqOUdgT6 EyklSy7wLOl5j7fcwFJPt2jx23WprRq/1zVENgNL9bciKx1dDEqoO+cXnA7r6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1647250096; 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; bh=N1nMKWa4Wte7sPkoEe/iOaoqC5bC9zSROJdxbx1qa0w=; b=Fc+0uLo1Eh5zrC4500rsdTcJ1ua5VoGeWR0cTG3V8Y2pW5k4+uBDBuVhyhrnGGv7zL8yst skjtocMsHIg0/kDw== 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/core] tick/rcu: Stop allowing RCU_SOFTIRQ in idle Cc: Frederic Weisbecker , Thomas Gleixner , Peter Zijlstra , "Paul E. McKenney" , Paul Menzel , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <164725009509.16921.13309674186697759166.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 0345691b24c076655ce8f0f4bfd24cba3467ccbd Gitweb: https://git.kernel.org/tip/0345691b24c076655ce8f0f4bfd24cba3= 467ccbd Author: Frederic Weisbecker AuthorDate: Tue, 08 Feb 2022 17:16:34 +01:00 Committer: Frederic Weisbecker CommitterDate: Mon, 07 Mar 2022 23:01:34 +01:00 tick/rcu: Stop allowing RCU_SOFTIRQ in idle RCU_SOFTIRQ used to be special in that it could be raised on purpose within the idle path to prevent from stopping the tick. Some code still prevents from unnecessary warnings related to this specific behaviour while entering in dynticks-idle mode. However the nohz layout has changed quite a bit in ten years, and the removal of CONFIG_RCU_FAST_NO_HZ has been the final straw to this safe-conduct. Now the RCU_SOFTIRQ vector is expected to be raised from sane places. A remaining corner case is admitted though when the vector is invoked in fragile hotplug path. Signed-off-by: Frederic Weisbecker Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Paul E. McKenney Cc: Paul Menzel --- include/linux/interrupt.h | 8 +++++- kernel/time/tick-sched.c | 50 ++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 9367f1c..9613326 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -579,7 +579,13 @@ enum NR_SOFTIRQS }; =20 -#define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ)) +/* + * Ignoring the RCU vector after ksoftirqd is parked is fine + * because: + * 1) rcutree_migrate_callbacks() takes care of the queue. + * 2) rcu_report_dead() reports the final quiescent states. + */ +#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ)) =20 /* map softirq index to softirq name. update 'softirq_to_name' in * kernel/softirq.c when adding a new softirq. diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 566ad5b..2d76c91 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -999,6 +999,45 @@ static void tick_nohz_full_update_tick(struct tick_sch= ed *ts) __tick_nohz_full_update_tick(ts, ktime_get()); } =20 +/* + * A pending softirq outside an IRQ (or softirq disabled section) context + * should be waiting for ksoftirqd to handle it. Therefore we shouldn't + * reach here due to the need_resched() early check in can_stop_idle_tick(= ). + * + * However if we are between CPUHP_AP_SMPBOOT_THREADS and CPU_TEARDOWN_CPU= on the + * cpu_down() process, softirqs can still be raised while ksoftirqd is par= ked, + * triggering the below since wakep_softirqd() is ignored. + * + */ +static bool report_idle_softirq(void) +{ + static int ratelimit; + unsigned int pending =3D local_softirq_pending(); + + if (likely(!pending)) + return false; + + /* Some softirqs claim to be safe against hotplug and ksoftirqd parking */ + if (!cpu_active(smp_processor_id())) { + pending &=3D ~SOFTIRQ_HOTPLUG_SAFE_MASK; + if (!pending) + return false; + } + + if (ratelimit < 10) + return false; + + /* On RT, softirqs handling may be waiting on some lock */ + if (!local_bh_blocked()) + return false; + + pr_warn("NOHZ tick-stop error: local softirq work is pending, handler #%0= 2x!!!\n", + pending); + ratelimit++; + + return true; +} + static bool can_stop_idle_tick(int cpu, struct tick_sched *ts) { /* @@ -1025,17 +1064,8 @@ static bool can_stop_idle_tick(int cpu, struct tick_= sched *ts) if (need_resched()) return false; =20 - if (unlikely(local_softirq_pending())) { - static int ratelimit; - - if (ratelimit < 10 && !local_bh_blocked() && - (local_softirq_pending() & SOFTIRQ_STOP_IDLE_MASK)) { - pr_warn("NOHZ tick-stop error: Non-RCU local softirq work is pending, h= andler #%02x!!!\n", - (unsigned int) local_softirq_pending()); - ratelimit++; - } + if (unlikely(report_idle_softirq())) return false; - } =20 if (tick_nohz_full_enabled()) { /*