* [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
@ 2026-12-04 7:51 Florent Carli via B4 Relay
2026-12-04 9:20 ` Sebastian Andrzej Siewior
2026-12-05 8:09 ` netdev-bot+sashiko
0 siblings, 2 replies; 5+ messages in thread
From: Florent Carli via B4 Relay @ 2026-12-04 7:51 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Sebastian Andrzej Siewior, Clark Williams,
Steven Rostedt, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev
Cc: netdev, linux-rt-devel, bpf, Toshiaki Makita, stable,
Florent Carli
From: Florent Carli <fcarli@gmail.com>
On PREEMPT_RT the callers of __veth_xdp_flush() are preemptible: the
BH-disabled sections of the transmit path do not disable preemption
there. A producer can be preempted after napi_schedule_prep() has
marked the peer's NAPI as scheduled, before __napi_schedule() wakes it
up. Every later producer then sees rx_notify_masked or
NAPI_STATE_SCHED set, queues its packet in the ptr_ring and returns,
and the NAPI sleeps until the preempted producer runs again. No lock is
held across that window, so priority inheritance cannot shorten it.
A low priority sender can thus hold the packets of every higher
priority sender of the same veth for as long as it stays preempted. We
hit this with IEC 61850 sampled values delivered through a veth whose
peer runs threaded NAPI, to a real-time reader on an isolated CPU: a
nice 19 sender was preempted for 4.33 ms between the two calls, the
peer's NAPI thread was not woken during that time, then was woken 4 us
after the sender ran again and polled 23 packets at once.
Mark and wake with preemption disabled, in a helper used by both
places that schedule the NAPI: __veth_xdp_flush() and the re-schedule
at the end of veth_poll(), which without threaded NAPI runs in whatever
task processes the softirq and has the same window on PREEMPT_RT.
__napi_schedule() takes raw locks only and masks interrupts itself, so
this is fine on PREEMPT_RT. Without PREEMPT_RT the callers already run
with BH, hence preemption, disabled and nothing changes.
Reproducer, in a PREEMPT_RT guest of this tree (4 vCPUs, each on its
own host CPU): a veth pair, the peer with GRO on and threaded NAPI,
its thread SCHED_FIFO 50 on CPU 2; a SCHED_FIFO 50 task sends a
timestamped packet every 250 us from CPU 1; a nice 19 task sends
100k packets/s on the same veth from CPU 3, where a SCHED_FIFO 10 task
runs 1 ms out of every 1.2 ms; a SCHED_FIFO 60 packet socket reader on
the peer measures the delay of each periodic packet, 480000 per run.
To make the race frequent, the test kernels also delay 50 us between
napi_schedule_prep() and __napi_schedule() (not part of this patch):
> 1 ms 0.5-1 ms max
window widened, before 20744 182358 4.5 ms
window widened, after 0 0 0.34 ms
window widened, no preemption, before 0 0 0.14 ms
actual window, before 2 7 1.2 ms
actual window, after 0 3 0.97 ms
The guest alone, without the other senders, showed 0 to 8 packets
over 1 ms in the same time.
Tested on this tree with PREEMPT_RT: the reproducer above, and
tools/testing/selftests/net/veth.sh in a 4-vCPU guest (all 60 checks
pass).
Fixes: 948d4f214fde ("veth: Add driver XDP")
Cc: stable@vger.kernel.org
Signed-off-by: Florent Carli <fcarli@gmail.com>
---
Notes (not part of the commit message):
- napi_schedule() chains the same two steps and has the same window
when called from a preemptible context on PREEMPT_RT. Fixing it there
would cover other drivers too; this patch keeps to veth, whose
producers run in task context. I can look at the generic helper
instead if that is preferred.
- Also tested on the system where we hit it: the Debian 7.3.4
PREEMPT_RT kernel with only veth.ko rebuilt with this patch, and a
nice 19 task sending 2000 packets/s through the same veth as the
sampled values. Without the patch: 6 late (3 over 3 ms) and 2 lost
sampled values in 30 min, the first after 14 min. With it: none in
60 min.
- The reproducer (a small C program and the scripts that build and boot
the guest) can be posted if useful.
- The analysis, the reproducer and this patch were prepared with an AI
coding assistant (Claude); I reviewed and tested them and stand by
them.
---
drivers/net/veth.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index faa837acea7b7ec14445ce54708bb4dd2b9d7fd7..a67a608e9ed1afe999be6d2cc7107a8bad40593b 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -299,15 +299,26 @@ static void veth_ptr_free(void *ptr)
kfree_skb(ptr);
}
-static void __veth_xdp_flush(struct veth_rq *rq)
+/* Mark the NAPI scheduled and wake it up. Once it is marked, the other
+ * producers leave the wake-up to this caller. On PREEMPT_RT the callers
+ * are preemptible: do not let a preemption hold the wake-up back.
+ */
+static void veth_napi_schedule(struct veth_rq *rq)
{
- /* Write ptr_ring before reading rx_notify_masked */
- smp_mb();
- if (!READ_ONCE(rq->rx_notify_masked) &&
- napi_schedule_prep(&rq->xdp_napi)) {
+ preempt_disable();
+ if (napi_schedule_prep(&rq->xdp_napi)) {
WRITE_ONCE(rq->rx_notify_masked, true);
__napi_schedule(&rq->xdp_napi);
}
+ preempt_enable();
+}
+
+static void __veth_xdp_flush(struct veth_rq *rq)
+{
+ /* Write ptr_ring before reading rx_notify_masked */
+ smp_mb();
+ if (!READ_ONCE(rq->rx_notify_masked))
+ veth_napi_schedule(rq);
}
static int veth_xdp_rx(struct veth_rq *rq, struct sk_buff *skb)
@@ -999,12 +1010,8 @@ static int veth_poll(struct napi_struct *napi, int budget)
if (done < budget && napi_complete_done(napi, done)) {
/* Write rx_notify_masked before reading ptr_ring */
smp_store_mb(rq->rx_notify_masked, false);
- if (unlikely(!__ptr_ring_empty(&rq->xdp_ring))) {
- if (napi_schedule_prep(&rq->xdp_napi)) {
- WRITE_ONCE(rq->rx_notify_masked, true);
- __napi_schedule(&rq->xdp_napi);
- }
- }
+ if (unlikely(!__ptr_ring_empty(&rq->xdp_ring)))
+ veth_napi_schedule(rq);
}
/* Release backpressure per NAPI poll */
---
base-commit: 90ae4042bd9f35a9098d14b1a12a43df9b326e2b
change-id: 20261203-veth-napi-rt-1f9678fde1a4
Best regards,
--
Florent Carli <fcarli@gmail.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
2026-12-04 7:51 [PATCH net] veth: disable preemption between the NAPI mark and its wake-up Florent Carli via B4 Relay
@ 2026-12-04 9:20 ` Sebastian Andrzej Siewior
2026-12-04 10:38 ` Florent Carli
2026-12-05 8:09 ` netdev-bot+sashiko
1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-12-04 9:20 UTC (permalink / raw)
To: fcarli
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Clark Williams, Steven Rostedt, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, netdev, linux-rt-devel, bpf, Toshiaki Makita,
stable
On 2026-12-04 08:51:52 [+0100], Florent Carli via B4 Relay wrote:
> From: Florent Carli <fcarli@gmail.com>
>
> On PREEMPT_RT the callers of __veth_xdp_flush() are preemptible: the
> BH-disabled sections of the transmit path do not disable preemption
> there. A producer can be preempted after napi_schedule_prep() has
> marked the peer's NAPI as scheduled, before __napi_schedule() wakes it
> up. Every later producer then sees rx_notify_masked or
> NAPI_STATE_SCHED set, queues its packet in the ptr_ring and returns,
> and the NAPI sleeps until the preempted producer runs again. No lock is
> held across that window, so priority inheritance cannot shorten it.
Right but if you schedule NAPI at low priority in a BH disabled section,
then the NAPI callback is invoked once BH is enabled again. So there is
no gain.
> A low priority sender can thus hold the packets of every higher
> priority sender of the same veth for as long as it stays preempted. We
> hit this with IEC 61850 sampled values delivered through a veth whose
> peer runs threaded NAPI, to a real-time reader on an isolated CPU: a
> nice 19 sender was preempted for 4.33 ms between the two calls, the
> peer's NAPI thread was not woken during that time, then was woken 4 us
> after the sender ran again and polled 23 packets at once.
I *think* if you have critical sender in your environment then it should
not run at low priority.
…
> Reproducer, in a PREEMPT_RT guest of this tree (4 vCPUs, each on its
> own host CPU): a veth pair, the peer with GRO on and threaded NAPI,
> its thread SCHED_FIFO 50 on CPU 2; a SCHED_FIFO 50 task sends a
so this needed, threaded NAPI. Otherwise the NAPI task would remain in
your context and you gain nothing. With this change you push it to
another thread.
> timestamped packet every 250 us from CPU 1; a nice 19 task sends
> 100k packets/s on the same veth from CPU 3, where a SCHED_FIFO 10 task
> runs 1 ms out of every 1.2 ms; a SCHED_FIFO 60 packet socket reader on
> the peer measures the delay of each periodic packet, 480000 per run.
> To make the race frequent, the test kernels also delay 50 us between
> napi_schedule_prep() and __napi_schedule() (not part of this patch):
You have low priority sender and high prio sender and when the low
priority one owns NAPI and the high priority one stuffs packets into
queue without processing.
I would argue that you shouldn't have a nice-19 task sending packets.
With real hardware, the traffic is usually split into high and low
priority. For that NICs provide queues and you can configure them.
This is something I would expect one to do.
Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
2026-12-04 9:20 ` Sebastian Andrzej Siewior
@ 2026-12-04 10:38 ` Florent Carli
0 siblings, 0 replies; 5+ messages in thread
From: Florent Carli @ 2026-12-04 10:38 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Clark Williams, Steven Rostedt, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Stanislav Fomichev, netdev, linux-rt-devel, bpf, Toshiaki Makita,
stable
> Right but if you schedule NAPI at low priority in a BH disabled section,
> then the NAPI callback is invoked once BH is enabled again. So there is
> no gain.
Agreed for non-threaded NAPI: the poll then runs in the low priority
task at local_bh_enable(), and the patch changes nothing there. It
matters with threaded NAPI, where __napi_schedule() only wakes the NAPI
thread. On PREEMPT_RT, threaded NAPI is how the receive path gets a
priority and a CPU of its own; without it, the poll runs at the
priority of whichever task scheduled it, which is your point. The
backlog follows the same logic on PREEMPT_RT, where its NAPI always
runs in the backlog_napi threads. I will state this scope in the
commit message.
> I *think* if you have critical sender in your environment then it should
> not run at low priority.
[...]
> I would argue that you shouldn't have a nice-19 task sending packets.
The nice 19 sender is in the reproducer on purpose: it stands for the
traffic we cannot control. Our critical sender runs SCHED_FIFO, but the
same host also runs ordinary tasks, and any of them can send ARP, ND or
MLD frames that reach the reader's veth. No configuration can make all
of them RT.
On PREEMPT_RT, these ordinary tasks also carry frames that are not
theirs. Without PREEMPT_RT_NEEDS_BH_LOCK, a task that leaves its
outermost BH section runs the pending softirqs of its CPU. In our setup
the frames reach the reader's veth from a veth without NAPI, so they go
through the per-CPU backlog, and whichever task runs NET_RX next on
that CPU forwards them and calls veth_xmit() on the reader's veth. With
ftrace histograms we counted a SCHED_OTHER thread of the publishing
process, which sends nothing on that link, doing about 200 such calls
per reader in two hours. The set of tasks that call veth_xmit() on a
given veth follows from who runs the softirq on each CPU, and the
application cannot keep it to RT tasks.
To show the inversion without the widened window of the reproducer, I
ran it on the unmodified net tree (90ae4042bd9f) and on the same tree
with this patch only, same config, both guests at once on separate
host cores. The FIFO 10 task on the nice 19 sender's CPU ran bursts of
1, 4 and 10 ms, 15 min each. Worst delay of the SCHED_FIFO periodic
stream, and in brackets the episodes of 0.5 ms or more:
FIFO 10 bursts unpatched patched
1 ms every 1.2 ms 1.6 ms (14) 0.28 ms (0)
4 ms every 5 ms 3.9 ms (1) 1.1 ms (1)
10 ms every 12 ms 9.8 ms (4) 1.0 ms (4)
Without the patch, the worst delay follows the length of the bursts of
a task that has nothing to do with networking: the FIFO 50 stream
waits for the FIFO 10 task, through the nice 19 sender that holds the
wake-up. With the patch, it stays within the noise of the guests,
which reached 1.5 ms (patched) and 4.7 ms (unpatched) in a first phase
without any load. On the system described in the notes (Debian 7.3.4
PREEMPT_RT, no test change), the patch took the reader from 6 late
(3 over 3 ms) and 2 lost frames in 30 min to none in 60 min.
> With real hardware, the traffic is usually split into high and low
> priority. For that NICs provide queues and you can configure them.
veth has queues as well, and steering the periodic frames to an rx
queue of their own would keep the ordinary traffic away from that
queue's NAPI. Its producers would still be the tasks that happen to
carry these frames, as above. Our setup also has event frames, just as
critical, that RT threads send from housekeeping CPUs: there, any
ordinary task that leaves a BH section can carry them to veth_xmit().
On a real NIC, the NAPI of an rx queue is scheduled by that queue's
interrupt, from hardirq or from its RT irq thread. On veth, every
sender schedules the peer's NAPI at its own priority, and nothing
boosts the one that set NAPI_STATE_SCHED.
Without PREEMPT_RT the patch changes nothing, since BH disabled already
implies preemption disabled. With PREEMPT_RT the non-preemptible
section covers napi_schedule_prep() and the wakeup of the NAPI thread.
For v2 I would use preempt_disable_nested(), as
Documentation/core-api/real-time/differences.rst suggests for code that
relies on BH disabling preemption; it is a no-op without PREEMPT_RT.
Would a v2 with the commit message limited to the threaded NAPI case
work for you?
Thanks,
Florent
On Fri, Dec 4, 2026 at 10:20 AM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> On 2026-12-04 08:51:52 [+0100], Florent Carli via B4 Relay wrote:
> > From: Florent Carli <fcarli@gmail.com>
> >
> > On PREEMPT_RT the callers of __veth_xdp_flush() are preemptible: the
> > BH-disabled sections of the transmit path do not disable preemption
> > there. A producer can be preempted after napi_schedule_prep() has
> > marked the peer's NAPI as scheduled, before __napi_schedule() wakes it
> > up. Every later producer then sees rx_notify_masked or
> > NAPI_STATE_SCHED set, queues its packet in the ptr_ring and returns,
> > and the NAPI sleeps until the preempted producer runs again. No lock is
> > held across that window, so priority inheritance cannot shorten it.
>
> Right but if you schedule NAPI at low priority in a BH disabled section,
> then the NAPI callback is invoked once BH is enabled again. So there is
> no gain.
>
> > A low priority sender can thus hold the packets of every higher
> > priority sender of the same veth for as long as it stays preempted. We
> > hit this with IEC 61850 sampled values delivered through a veth whose
> > peer runs threaded NAPI, to a real-time reader on an isolated CPU: a
> > nice 19 sender was preempted for 4.33 ms between the two calls, the
> > peer's NAPI thread was not woken during that time, then was woken 4 us
> > after the sender ran again and polled 23 packets at once.
>
> I *think* if you have critical sender in your environment then it should
> not run at low priority.
> …
> > Reproducer, in a PREEMPT_RT guest of this tree (4 vCPUs, each on its
> > own host CPU): a veth pair, the peer with GRO on and threaded NAPI,
> > its thread SCHED_FIFO 50 on CPU 2; a SCHED_FIFO 50 task sends a
>
> so this needed, threaded NAPI. Otherwise the NAPI task would remain in
> your context and you gain nothing. With this change you push it to
> another thread.
>
> > timestamped packet every 250 us from CPU 1; a nice 19 task sends
> > 100k packets/s on the same veth from CPU 3, where a SCHED_FIFO 10 task
> > runs 1 ms out of every 1.2 ms; a SCHED_FIFO 60 packet socket reader on
> > the peer measures the delay of each periodic packet, 480000 per run.
> > To make the race frequent, the test kernels also delay 50 us between
> > napi_schedule_prep() and __napi_schedule() (not part of this patch):
>
> You have low priority sender and high prio sender and when the low
> priority one owns NAPI and the high priority one stuffs packets into
> queue without processing.
> I would argue that you shouldn't have a nice-19 task sending packets.
>
> With real hardware, the traffic is usually split into high and low
> priority. For that NICs provide queues and you can configure them.
>
> This is something I would expect one to do.
>
> Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
2026-12-04 7:51 [PATCH net] veth: disable preemption between the NAPI mark and its wake-up Florent Carli via B4 Relay
2026-12-04 9:20 ` Sebastian Andrzej Siewior
@ 2026-12-05 8:09 ` netdev-bot+sashiko
2026-12-05 8:20 ` Florent Carli
1 sibling, 1 reply; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 8:09 UTC (permalink / raw)
To: fcarli
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, bigeasy, clrkwllms,
rostedt, ast, daniel, hawk, john.fastabend, sdf, netdev,
linux-rt-devel, bpf, toshiaki.makita1, stable
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] With non-threaded NAPI on PREEMPT_RT, the veth fix does not
remove the priority inversion the commit message describes.
--
veth: disable preemption between the NAPI mark and its wake-up
This patch adds a veth_napi_schedule() helper. The helper calls
napi_schedule_prep() and __napi_schedule() with preemption disabled.
__veth_xdp_flush() and the re-schedule at the end of veth_poll() now use
it. The aim is to stop a preempted low priority producer on PREEMPT_RT
from holding back the NAPI wake-up for every other producer of the same
veth.
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index faa837acea7b7..a67a608e9ed1a 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -299,15 +299,26 @@ static void veth_ptr_free(void *ptr)
> kfree_skb(ptr);
> }
>
> -static void __veth_xdp_flush(struct veth_rq *rq)
> +/* Mark the NAPI scheduled and wake it up. Once it is marked, the other
> + * producers leave the wake-up to this caller. On PREEMPT_RT the callers
> + * are preemptible: do not let a preemption hold the wake-up back.
> + */
> +static void veth_napi_schedule(struct veth_rq *rq)
> {
> - /* Write ptr_ring before reading rx_notify_masked */
> - smp_mb();
> - if (!READ_ONCE(rq->rx_notify_masked) &&
> - napi_schedule_prep(&rq->xdp_napi)) {
> + preempt_disable();
> + if (napi_schedule_prep(&rq->xdp_napi)) {
> WRITE_ONCE(rq->rx_notify_masked, true);
> __napi_schedule(&rq->xdp_napi);
> }
> + preempt_enable();
> +}
[Severity: High]
Does this close the window when the peer NAPI is not threaded? That is
the default for veth, which registers its NAPI with plain
netif_napi_add().
In that mode __napi_schedule() does not wake a task.
____napi_schedule() only queues the NAPI on the local CPU and raises the
softirq:
net/core/dev.c:____napi_schedule() {
...
list_add_tail(&napi->poll_list, &sd->poll_list);
WRITE_ONCE(napi->list_owner, smp_processor_id());
if (!sd->in_net_rx_action)
raise_softirq_irqoff(NET_RX_SOFTIRQ);
}
On PREEMPT_RT, in_interrupt() is true while the current task has BH
disabled, because softirq_count() there comes from
current->softirq_disable_cnt. So raise_softirq_irqoff() skips
wakeup_softirqd():
kernel/softirq.c:raise_softirq_irqoff() {
...
if (!in_interrupt() && should_wake_ksoftirqd())
wakeup_softirqd();
}
The pending NET_RX softirq then runs only when the same producer
reaches its own local_bh_enable().
Take a nice 19 sender on CPU3 and a high priority sender on CPU1:
CPU3 (nice 19)
veth_xmit()
__veth_xdp_flush()
veth_napi_schedule()
napi_schedule_prep() /* sets NAPI_STATE_SCHED */
rx_notify_masked = true
__napi_schedule() /* only queued on CPU3 poll_list */
preempt_enable()
<preempted by a SCHED_FIFO task before local_bh_enable()>
CPU1 (SCHED_FIFO)
veth_xmit()
__veth_xdp_flush()
READ_ONCE(rq->rx_notify_masked) == true, return
Wouldn't CPU1's packets then stay in xdp_ring until the nice 19 task
runs again? That is the same stall the commit message describes.
The veth_poll() hunk seems to have the same problem. The commit message
says:
"and the re-schedule at the end of veth_poll(), which without threaded
NAPI runs in whatever task processes the softirq and has the same
window on PREEMPT_RT."
In non-threaded mode, veth_poll() runs inside that task's
net_rx_action(). It already owns NAPI_STATE_SCHED for the whole poll,
and the poll can be preempted. The re-scheduled NAPI goes back on the
same CPU's poll_list with in_net_rx_action set. So it is only served
when that task resumes, whether it was preempted before or after
__napi_schedule().
In threaded mode, veth_poll() runs in the NAPI thread and re-schedules
itself. There doesn't seem to be a cross-task inversion there for
preempt_disable() to fix.
As far as I can tell, this only fixes the threaded NAPI producer case
that the reproducer used. Could the comment on veth_napi_schedule() and
the commit message be limited to that case? Or does the non-threaded
case need a different approach, such as covering the whole BH-disabled
section, or requiring threaded NAPI on PREEMPT_RT?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-veth-napi-rt-v1-1-02b900f75067%40gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
2026-12-05 8:09 ` netdev-bot+sashiko
@ 2026-12-05 8:20 ` Florent Carli
0 siblings, 0 replies; 5+ messages in thread
From: Florent Carli @ 2026-12-05 8:20 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, bigeasy, clrkwllms,
rostedt, ast, daniel, hawk, john.fastabend, sdf, netdev,
linux-rt-devel, bpf, toshiaki.makita1, stable
> - [High] With non-threaded NAPI on PREEMPT_RT, the veth fix does not
> remove the priority inversion the commit message describes.
Right. Without threaded NAPI, __napi_schedule() only queues the NAPI on
the producer's CPU, and the poll runs when that producer reaches
local_bh_enable(). A preemption anywhere in that BH section holds the
packets of the other producers, before or after __napi_schedule(). The
patch only helps with threaded NAPI, where __napi_schedule() wakes the
NAPI thread. Sebastian made the same point.
> The veth_poll() hunk seems to have the same problem.
Agreed. Without threaded NAPI, the re-scheduled NAPI is served by the
task that runs the poll; with threaded NAPI, the thread re-schedules
itself. I will drop that hunk.
> Could the comment on veth_napi_schedule() and
> the commit message be limited to that case? Or does the non-threaded
> case need a different approach, such as covering the whole BH-disabled
> section, or requiring threaded NAPI on PREEMPT_RT?
v2 will limit the comment and the commit message to threaded NAPI.
Covering the whole H-disabled section would make the transmit path and
the poll non-preemptible, which PREEMPT_RT is designed to avoid. On
PREEMPT_RT, any NAPI that is not threaded runs in the softirq of the
task that scheduled it, at that task's priority; threaded NAPI is the
way out, as the backlog already does on PREEMPT_RT. Requiring it for
veth would change behaviour and belongs in net-next, outside this fix.
Sebastian, unless you see a reason to hold it, I will send v2 with
these changes on Monday.
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-05 8:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 7:51 [PATCH net] veth: disable preemption between the NAPI mark and its wake-up Florent Carli via B4 Relay
2026-12-04 9:20 ` Sebastian Andrzej Siewior
2026-12-04 10:38 ` Florent Carli
2026-12-05 8:09 ` netdev-bot+sashiko
2026-12-05 8:20 ` Florent Carli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox