mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wen.yang@linux.dev
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: Eric Dumazet <edumazet@google.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-rt-devel@list.kernel.org, linux-kernel@vger.kernel.org,
	Wen Yang <wen.yang@linux.dev>
Subject: [PATCH 01/15] Revert "net: Avoid the IPI to free the"
Date: Wed, 14 Oct 2026 01:58:35 +0800	[thread overview]
Message-ID: <3cbe89d9d68c4a6cde983624b6849a05373c6361.1791912669.git.wen.yang@linux.dev> (raw)
In-Reply-To: <cover.1791912669.git.wen.yang@linux.dev>

From: Wen Yang <wen.yang@linux.dev>

This reverts commit 8d152d22d9f056f87875f97aec016a65622abbf0.

That commit is an RT-only workaround. skb_attempt_defer_free() collects
skbs allocated on a remote CPU on a per-CPU list and, once the list passes
half its watermark, pokes that CPU with an IPI to raise NET_RX_SOFTIRQ so
the list gets drained. On PREEMPT_RT that IPI wakes ksoftirqd from hardirq
context, which is undesirable, so the commit redirected the deferred skb
recycling to a workqueue (sd->defer_work) instead.

It is reverted here for two reasons.

First, it is incomplete. It only covers the defer_list path. RPS steering
still pokes the remote CPU with an IPI from napi_schedule_rps(), and that
IPI handler (rps_trigger_softirq) still calls ____napi_schedule() ->
raise_softirq_irqoff(NET_RX_SOFTIRQ). That is the path that trips
do_softirq_post_smp_call_flush() on PREEMPT_RT, and the workaround does
nothing about it.

Second, it is superseded. The following patches backport the upstream
backlog-NAPI smpboot threads (dad6b9770263 and friends). With those,
use_backlog_threads() is unconditionally true on PREEMPT_RT, so both the
cross-CPU backlog enqueue and the defer_list purge wake a per-CPU
"backlog_napi/%u" thread with wake_up_process() instead of sending an IPI.
Deferred skbs are then freed from the same NAPI loop that is already going
to run, without the workqueue round-trip.

Reverting first restores the upstream 6.1 code shape so the rest of the
series applies unmodified.

Signed-off-by: Wen Yang <wen.yang@linux.dev>
---
 include/linux/netdevice.h |  4 ----
 net/core/dev.c            | 37 +++++++++----------------------------
 net/core/skbuff.c         |  7 +------
 3 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index fbd3b17463da..e97967ca2760 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3199,11 +3199,7 @@ struct softnet_data {
 	int			defer_count;
 	int			defer_ipi_scheduled;
 	struct sk_buff		*defer_list;
-#ifndef CONFIG_PREEMPT_RT
 	call_single_data_t	defer_csd;
-#else
-	struct work_struct	defer_work;
-#endif
 };
 
 static inline void input_queue_head_incr(struct softnet_data *sd)
diff --git a/net/core/dev.c b/net/core/dev.c
index 5d6ca8510227..f44ffac6cba6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4712,6 +4712,15 @@ static void rps_trigger_softirq(void *data)
 
 #endif /* CONFIG_RPS */
 
+/* Called from hardirq (IPI) context */
+static void trigger_rx_softirq(void *data)
+{
+	struct softnet_data *sd = data;
+
+	__raise_softirq_irqoff(NET_RX_SOFTIRQ);
+	smp_store_release(&sd->defer_ipi_scheduled, 0);
+}
+
 /*
  * Check if this softnet_data structure is another cpu one
  * If yes, queue it to our IPI list and return 1
@@ -6772,30 +6781,6 @@ static void skb_defer_free_flush(struct softnet_data *sd)
 	}
 }
 
-#ifndef CONFIG_PREEMPT_RT
-/* Called from hardirq (IPI) context */
-static void trigger_rx_softirq(void *data)
-{
-	struct softnet_data *sd = data;
-
-	__raise_softirq_irqoff(NET_RX_SOFTIRQ);
-	smp_store_release(&sd->defer_ipi_scheduled, 0);
-}
-
-#else
-
-static void trigger_rx_softirq(struct work_struct *defer_work)
-{
-	struct softnet_data *sd;
-
-	sd = container_of(defer_work, struct softnet_data, defer_work);
-	smp_store_release(&sd->defer_ipi_scheduled, 0);
-	local_bh_disable();
-	skb_defer_free_flush(sd);
-	local_bh_enable();
-}
-#endif
-
 static __latent_entropy void net_rx_action(struct softirq_action *h)
 {
 	struct softnet_data *sd = this_cpu_ptr(&softnet_data);
@@ -11620,11 +11605,7 @@ static int __init net_dev_init(void)
 		INIT_CSD(&sd->csd, rps_trigger_softirq, sd);
 		sd->cpu = i;
 #endif
-#ifndef CONFIG_PREEMPT_RT
 		INIT_CSD(&sd->defer_csd, trigger_rx_softirq, sd);
-#else
-		INIT_WORK(&sd->defer_work, trigger_rx_softirq);
-#endif
 		spin_lock_init(&sd->defer_lock);
 
 		init_gro_hash(&sd->backlog);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 665be0ad4b8d..a66066bc9861 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6746,11 +6746,6 @@ nodefer:	__kfree_skb(skb);
 	/* Make sure to trigger NET_RX_SOFTIRQ on the remote CPU
 	 * if we are unlucky enough (this seems very unlikely).
 	 */
-	if (unlikely(kick) && !cmpxchg(&sd->defer_ipi_scheduled, 0, 1)) {
-#ifndef CONFIG_PREEMPT_RT
+	if (unlikely(kick) && !cmpxchg(&sd->defer_ipi_scheduled, 0, 1))
 		smp_call_function_single_async(cpu, &sd->defer_csd);
-#else
-		schedule_work_on(cpu, &sd->defer_work);
-#endif
-	}
 }
-- 
2.25.1


  reply	other threads:[~2026-10-13 17:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 17:58 [PATCH v6.1-rt 00/15] net: Backport backlog-NAPI threads to resolve PREEMPT_RT softirq warning in SMP flush wen.yang
2026-10-13 17:58 ` wen.yang [this message]
2026-10-13 17:58 ` [PATCH 02/15] net: avoid irqsave in skb_defer_free_flush wen.yang
2026-10-13 17:58 ` [PATCH 03/15] net: napi_schedule_rps() cleanup wen.yang
2026-10-13 17:58 ` [PATCH 04/15] net: add softnet_data.in_net_rx_action wen.yang
2026-10-13 17:58 ` [PATCH 05/15] net: optimize napi_schedule_rps() wen.yang
2026-10-13 17:58 ` [PATCH 06/15] net: optimize ____napi_schedule() to avoid extra NET_RX_SOFTIRQ wen.yang
2026-10-13 17:58 ` [PATCH 07/15] net: add debugging checks in skb_attempt_defer_free() wen.yang
2026-10-13 17:58 ` [PATCH 08/15] net: do not provide hard irq safety for sd->defer_lock wen.yang
2026-10-13 17:58 ` [PATCH 09/15] net: move skb_defer_free_flush() up wen.yang
2026-10-13 18:02 ` [PATCH 10/15] net: make napi_threaded_poll() aware of sd->defer_list wen.yang
2026-10-13 18:02 ` [PATCH 11/15] net: optimize napi_threaded_poll() vs RPS/RFS wen.yang
2026-10-13 18:02 ` [PATCH 12/15] net: Remove conditional threaded-NAPI wakeup based on task state wen.yang
2026-10-13 18:02 ` [PATCH 13/15] net: Use backlog-NAPI to clean up the defer_list wen.yang
2026-10-13 18:02 ` [PATCH 14/15] net: Allow to use SMP threads for backlog NAPI wen.yang
2026-10-13 18:02 ` [PATCH 15/15] net: Rename rps_lock to backlog_lock wen.yang

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=3cbe89d9d68c4a6cde983624b6849a05373c6361.1791912669.git.wen.yang@linux.dev \
    --to=wen.yang@linux.dev \
    --cc=bigeasy@linutronix.de \
    --cc=brouer@redhat.com \
    --cc=clrkwllms@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@list.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®