From nobody Mon Jun 29 14:44:41 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 EF6DAC433F5 for ; Tue, 8 Feb 2022 16:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382878AbiBHQQs (ORCPT ); Tue, 8 Feb 2022 11:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239418AbiBHQQq (ORCPT ); Tue, 8 Feb 2022 11:16:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA0EC061579 for ; Tue, 8 Feb 2022 08:16:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2A4F2B81BDD for ; Tue, 8 Feb 2022 16:16:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 795C3C340EF; Tue, 8 Feb 2022 16:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644337002; bh=Vs+f44lnIytigGrVrSLdddTGPc/R0+RbyevkTBO4lDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQfLUiJyd68l6VijxFrp22OLIznr/JZtNc4GHEChy1E7TVLfk8fpIqn+2fU5A0QJo vTEifznow0XuSy7yFo0DLtu6VOa3+hpfjr1JMpQGrGOt4/lse1f74875y9Kixt9IG5 st7bHcha7BbGAvcoAG0te44ocZif55surenEU+UmqYGVZrFLdCsae9UzNMK3pXlV/T /4L+1NBBkAKYZXe8xCrXaYkv1zr+feR2q75HpreGKHH9whSVW4dhOB8nPeo+XFgQTa KG2mmgHLqSYEtBU6aPjMvwHtea50vV/0IesNGkA18jEV2dYiLAXrugFjJATYJSln9N sqcFF56iUM8Ug== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , "Paul E . McKenney" , Peter Zijlstra , Thomas Gleixner , Paul Menzel Subject: [PATCH 1/3] tick/rcu: Remove obsolete rcu_needs_cpu() parameters Date: Tue, 8 Feb 2022 17:16:33 +0100 Message-Id: <20220208161635.544701-2-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208161635.544701-1-frederic@kernel.org> References: <20220208161635.544701-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With the removal of CONFIG_RCU_FAST_NO_HZ, the parameters in rcu_needs_cpu() are not necessary anymore. Simply remove them. Signed-off-by: Frederic Weisbecker Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Paul E. McKenney Cc: Paul Menzel Tested-by: Paul Menzel --- include/linux/rcutiny.h | 3 +-- include/linux/rcutree.h | 2 +- kernel/rcu/tree.c | 3 +-- kernel/time/tick-sched.c | 10 ++++------ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h index 858f4d429946..5fed476f977f 100644 --- a/include/linux/rcutiny.h +++ b/include/linux/rcutiny.h @@ -64,9 +64,8 @@ static inline void rcu_softirq_qs(void) rcu_tasks_qs(current, (preempt)); \ } while (0) =20 -static inline int rcu_needs_cpu(u64 basemono, u64 *nextevt) +static inline int rcu_needs_cpu(void) { - *nextevt =3D KTIME_MAX; return 0; } =20 diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h index 53209d669400..6cc91291d078 100644 --- a/include/linux/rcutree.h +++ b/include/linux/rcutree.h @@ -19,7 +19,7 @@ =20 void rcu_softirq_qs(void); void rcu_note_context_switch(bool preempt); -int rcu_needs_cpu(u64 basem, u64 *nextevt); +int rcu_needs_cpu(void); void rcu_cpu_stall_reset(void); =20 /* diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index a4c25a6283b0..80faf2273ce9 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1086,9 +1086,8 @@ void rcu_irq_enter_irqson(void) * Just check whether or not this CPU has non-offloaded RCU callbacks * queued. */ -int rcu_needs_cpu(u64 basemono, u64 *nextevt) +int rcu_needs_cpu(void) { - *nextevt =3D KTIME_MAX; return !rcu_segcblist_empty(&this_cpu_ptr(&rcu_data)->cblist) && !rcu_rdp_is_offloaded(this_cpu_ptr(&rcu_data)); } diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 17a283ce2b20..2abb5112feb9 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -768,7 +768,7 @@ static inline bool local_timer_softirq_pending(void) =20 static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) { - u64 basemono, next_tick, next_tmr, next_rcu, delta, expires; + u64 basemono, next_tick, delta, expires; unsigned long basejiff; unsigned int seq; =20 @@ -791,7 +791,7 @@ static ktime_t tick_nohz_next_event(struct tick_sched *= ts, int cpu) * minimal delta which brings us back to this place * immediately. Lather, rinse and repeat... */ - if (rcu_needs_cpu(basemono, &next_rcu) || arch_needs_cpu() || + if (rcu_needs_cpu() || arch_needs_cpu() || irq_work_needs_cpu() || local_timer_softirq_pending()) { next_tick =3D basemono + TICK_NSEC; } else { @@ -802,10 +802,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched = *ts, int cpu) * disabled this also looks at the next expiring * hrtimer. */ - next_tmr =3D get_next_timer_interrupt(basejiff, basemono); - ts->next_timer =3D next_tmr; - /* Take the next rcu event into account */ - next_tick =3D next_rcu < next_tmr ? next_rcu : next_tmr; + next_tick =3D get_next_timer_interrupt(basejiff, basemono); + ts->next_timer =3D next_tick; } =20 /* --=20 2.25.1 From nobody Mon Jun 29 14:44:41 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 80696C433FE for ; Tue, 8 Feb 2022 16:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382894AbiBHQQu (ORCPT ); Tue, 8 Feb 2022 11:16:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382880AbiBHQQs (ORCPT ); Tue, 8 Feb 2022 11:16:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A9ABC061578 for ; Tue, 8 Feb 2022 08:16:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6497B81BDF for ; Tue, 8 Feb 2022 16:16:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55849C340EC; Tue, 8 Feb 2022 16:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644337004; bh=HiUrfd8RertoPB+w3nt8On3GrC91eaaqsyW1vNKbAKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Su+MP0ViQpwp05yXIQ2MnQvNW5sP/evsg02ijkWOXX0w8tyEaQbWJfTaO4n7TyvEX kem1PliDn6FKMzcPF5mqUaGC2jPbVRCnQXomelxe5HsH52foVOymGL787wNbS3BRnG qCgSEkClF+6lBxR025Jx7wOzVeAK/QPG8bTCKDnQYQ6bAgQN8RVPplfabODO4T1LFp 2g2w2HVd31kg+dTA9baOoAMkioxD1V39aEdhHVCPVs3PcEffrjsvguy6ssbc50DUUD cIMXgf1v888WfaWwQfI5bgsq5SSj6WlwTt8hKSzFOFryJQOKnJaDImAu+dmVP8J60Z vjSqwRXEK+zYg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , "Paul E . McKenney" , Peter Zijlstra , Thomas Gleixner , Paul Menzel Subject: [PATCH 2/3] tick/rcu: Stop allowing RCU_SOFTIRQ in idle Date: Tue, 8 Feb 2022 17:16:34 +0100 Message-Id: <20220208161635.544701-3-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208161635.544701-1-frederic@kernel.org> References: <20220208161635.544701-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Tested-by: 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 9367f1cb2e3c..9613326d2f8a 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 2abb5112feb9..1e923f307f06 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -982,6 +982,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) { /* @@ -1008,17 +1047,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()) { /* --=20 2.25.1 From nobody Mon Jun 29 14:44:41 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 B01D7C433EF for ; Tue, 8 Feb 2022 16:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382927AbiBHQQz (ORCPT ); Tue, 8 Feb 2022 11:16:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382881AbiBHQQs (ORCPT ); Tue, 8 Feb 2022 11:16:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9678AC061579 for ; Tue, 8 Feb 2022 08:16:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2DC75616AD for ; Tue, 8 Feb 2022 16:16:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32B65C340EF; Tue, 8 Feb 2022 16:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644337006; bh=RqIk4EnOdjCYrxJGCZyCg+wmvIsqy3TKXzcC2Wpnv+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLOx/H7YJ24xl8oOEqYH0a0xEAGRe469GYLbMo1UGHz8Vkqa5QhUkXk/Y321AOVmm OkoTr8rBESWWnjjicWK0As70+z6d66hPsIMgFG5uO5lxEzJDpntZgVsGia7sLSeYfP QY59mNjPG1uFO/0rmkg63cErj1u3ZHYqgjkF3jKyurRAObaFprzTA5+6dfY0aIwTLm gbukNz1jzR6Qxmp1BpPkZWPJaONKVQYgS7Qvf/6khVdm14RpbZBi22ftmPQqCwM/b4 hRZLkSBIuUamZgeGXfIoE1mfVPBNA8q/pVlmilDh5isaHD71x+l0+GftJSPT8BLfGF +Lvu989ljuGHA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , "Paul E . McKenney" , Peter Zijlstra , Thomas Gleixner , Paul Menzel Subject: [PATCH 3/3] lib/irq_poll: Declare IRQ_POLL softirq vector as ksoftirqd-parking safe Date: Tue, 8 Feb 2022 17:16:35 +0100 Message-Id: <20220208161635.544701-4-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208161635.544701-1-frederic@kernel.org> References: <20220208161635.544701-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The following warning may appear while setting a CPU down: NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #20!!! The IRQ_POLL_SOFTIRQ vector can be raised during the hotplug cpu_down() path after ksoftirqd is parked and before the CPU actually dies. However this is handled afterward at the CPUHP_IRQ_POLL_DEAD stage where the queue gets migrated. Hence this warning can be considered spurious and the vector can join the "hotplug-safe" list. Reported-by: Paul Menzel Signed-off-by: Frederic Weisbecker Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Paul E. McKenney Cc: Paul Menzel Tested-by: Paul Menzel --- include/linux/interrupt.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 9613326d2f8a..f40754caaefa 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -580,12 +580,15 @@ enum }; =20 /* - * Ignoring the RCU vector after ksoftirqd is parked is fine - * because: - * 1) rcutree_migrate_callbacks() takes care of the queue. + * The following vectors can be safely ignored after ksoftirqd is parked: + * + * _ RCU: + * 1) rcutree_migrate_callbacks() migrates the queue. * 2) rcu_report_dead() reports the final quiescent states. + * + * _ IRQ_POLL: irq_poll_cpu_dead() migrates the queue */ -#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ)) +#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ) | BIT(IRQ_POLL_SOFTIRQ= )) =20 /* map softirq index to softirq name. update 'softirq_to_name' in * kernel/softirq.c when adding a new softirq. --=20 2.25.1