From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, K Prateek Nayak <kprateek.nayak@amd.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Felix Moessbauer <felix.moessbauer@siemens.com>,
Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: [PATCH 6.1 11/49] softirq: Allow raising SCHED_SOFTIRQ from SMP-call-function on RT kernel
Date: Thu, 30 Jan 2025 15:01:47 +0100 [thread overview]
Message-ID: <20250130140134.287151097@linuxfoundation.org> (raw)
In-Reply-To: <20250130140133.825446496@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <kprateek.nayak@amd.com>
commit 6675ce20046d149e1e1ffe7e9577947dee17aad5 upstream.
do_softirq_post_smp_call_flush() on PREEMPT_RT kernels carries a
WARN_ON_ONCE() for any SOFTIRQ being raised from an SMP-call-function.
Since do_softirq_post_smp_call_flush() is called with preempt disabled,
raising a SOFTIRQ during flush_smp_call_function_queue() can lead to
longer preempt disabled sections.
Since commit b2a02fc43a1f ("smp: Optimize
send_call_function_single_ipi()") IPIs to an idle CPU in
TIF_POLLING_NRFLAG mode can be optimized out by instead setting
TIF_NEED_RESCHED bit in idle task's thread_info and relying on the
flush_smp_call_function_queue() in the idle-exit path to run the
SMP-call-function.
To trigger an idle load balancing, the scheduler queues
nohz_csd_function() responsible for triggering an idle load balancing on
a target nohz idle CPU and sends an IPI. Only now, this IPI is optimized
out and the SMP-call-function is executed from
flush_smp_call_function_queue() in do_idle() which can raise a
SCHED_SOFTIRQ to trigger the balancing.
So far, this went undetected since, the need_resched() check in
nohz_csd_function() would make it bail out of idle load balancing early
as the idle thread does not clear TIF_POLLING_NRFLAG before calling
flush_smp_call_function_queue(). The need_resched() check was added with
the intent to catch a new task wakeup, however, it has recently
discovered to be unnecessary and will be removed in the subsequent
commit after which nohz_csd_function() can raise a SCHED_SOFTIRQ from
flush_smp_call_function_queue() to trigger an idle load balance on an
idle target in TIF_POLLING_NRFLAG mode.
nohz_csd_function() bails out early if "idle_cpu()" check for the
target CPU, and does not lock the target CPU's rq until the very end,
once it has found tasks to run on the CPU and will not inhibit the
wakeup of, or running of a newly woken up higher priority task. Account
for this and prevent a WARN_ON_ONCE() when SCHED_SOFTIRQ is raised from
flush_smp_call_function_queue().
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20241119054432.6405-2-kprateek.nayak@amd.com
Tested-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/softirq.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -294,17 +294,24 @@ static inline void invoke_softirq(void)
wakeup_softirqd();
}
+#define SCHED_SOFTIRQ_MASK BIT(SCHED_SOFTIRQ)
+
/*
* flush_smp_call_function_queue() can raise a soft interrupt in a function
- * call. On RT kernels this is undesired and the only known functionality
- * in the block layer which does this is disabled on RT. If soft interrupts
- * get raised which haven't been raised before the flush, warn so it can be
+ * call. On RT kernels this is undesired and the only known functionalities
+ * are in the block layer which is disabled on RT, and in the scheduler for
+ * idle load balancing. If soft interrupts get raised which haven't been
+ * raised before the flush, warn if it is not a SCHED_SOFTIRQ so it can be
* investigated.
*/
void do_softirq_post_smp_call_flush(unsigned int was_pending)
{
- if (WARN_ON_ONCE(was_pending != local_softirq_pending()))
+ unsigned int is_pending = local_softirq_pending();
+
+ if (unlikely(was_pending != is_pending)) {
+ WARN_ON_ONCE(was_pending != (is_pending & ~SCHED_SOFTIRQ_MASK));
invoke_softirq();
+ }
}
#else /* CONFIG_PREEMPT_RT */
next prev parent reply other threads:[~2025-01-30 14:29 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 14:01 [PATCH 6.1 00/49] 6.1.128-rc1 review Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 01/49] ASoC: wm8994: Add depends on MFD core Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 02/49] ASoC: samsung: Add missing selects for MFD_WM8994 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 03/49] seccomp: Stub for !CONFIG_SECCOMP Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 04/49] scsi: iscsi: Fix redundant response for ISCSI_UEVENT_GET_HOST_STATS request Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 05/49] drm/amd/display: Use HW lock mgr for PSR1 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 06/49] irqchip/sunxi-nmi: Add missing SKIP_WAKE flag Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 07/49] ASoC: samsung: midas_wm1811: Map missing jack kcontrols Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 08/49] ASoC: samsung: Add missing depends on I2C Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 09/49] regmap: detach regmap from dev on regmap_exit Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 10/49] ipv6: Fix soft lockups in fib6_select_path under high next hop churn Greg Kroah-Hartman
2025-01-30 14:01 ` Greg Kroah-Hartman [this message]
2025-01-30 14:01 ` [PATCH 6.1 12/49] xfs: bump max fsgeom struct version Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 13/49] xfs: hoist freeing of rt data fork extent mappings Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 14/49] xfs: prevent rt growfs when quota is enabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 15/49] xfs: rt stubs should return negative errnos when rt disabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 16/49] xfs: fix units conversion error in xfs_bmap_del_extent_delay Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 17/49] xfs: make sure maxlen is still congruent with prod when rounding down Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 18/49] xfs: introduce protection for drop nlink Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 19/49] xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 20/49] xfs: allow read IO and FICLONE to run concurrently Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 21/49] xfs: factor out xfs_defer_pending_abort Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 22/49] xfs: abort intent items when recovery intents fail Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 23/49] xfs: only remap the written blocks in xfs_reflink_end_cow_extent Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 24/49] xfs: up(ic_sema) if flushing data device fails Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 25/49] xfs: fix internal error from AGFL exhaustion Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 26/49] xfs: inode recovery does not validate the recovered inode Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 27/49] xfs: clean up dqblk extraction Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 28/49] xfs: dquot recovery does not validate the recovered dquot Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 29/49] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 30/49] xfs: respect the stable writes flag on the RT device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 31/49] gfs2: Truncate address space when flipping GFS2_DIF_JDATA flag Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 32/49] io_uring: fix waiters missing wake ups Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 33/49] net: sched: fix ets qdisc OOB Indexing Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 34/49] block: fix integer overflow in BLKSECDISCARD Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 35/49] Revert "HID: multitouch: Add support for lenovo Y9000P Touchpad" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 36/49] vfio/platform: check the bounds of read/write syscalls Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 37/49] ext4: fix access to uninitialised lock in fc replay path Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 38/49] ipv4: ip_tunnel: Fix suspicious RCU usage warning in ip_tunnel_find() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 39/49] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 40/49] wifi: iwlwifi: add a few rate index validity checks Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 41/49] smb: client: fix UAF in async decryption Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 42/49] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 43/49] Revert "usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 44/49] ALSA: usb-audio: Add delay quirk for USB Audio Device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 45/49] Input: atkbd - map F23 key to support default copilot shortcut Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 46/49] Input: xpad - add unofficial Xbox 360 wireless receiver clone Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 47/49] Input: xpad - add support for wooting two he (arm) Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 48/49] smb: client: fix NULL ptr deref in crypto_aead_setkey() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 49/49] ASoC: samsung: midas_wm1811: Fix Headphone Switch control creation Greg Kroah-Hartman
2025-01-30 17:58 ` [PATCH 6.1 00/49] 6.1.128-rc1 review Mark Brown
2025-01-30 21:31 ` Florian Fainelli
2025-01-31 5:38 ` Jon Hunter
2025-01-31 12:57 ` Pavel Machek
2025-01-31 13:57 ` Ron Economos
2025-01-31 15:26 ` Naresh Kamboju
2025-01-31 16:58 ` Muhammad Usama Anjum
2025-02-01 8:15 ` [PATCH 6.1] " Hardik Garg
2025-02-01 12:19 ` [PATCH 6.1 00/49] " Peter Schneider
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250130140134.287151097@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=felix.moessbauer@siemens.com \
--cc=florian.bezdeka@siemens.com \
--cc=kprateek.nayak@amd.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.