From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: fcarli@gmail.com
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
netdev@vger.kernel.org, linux-rt-devel@lists.linux.dev,
bpf@vger.kernel.org, Toshiaki Makita <toshiaki.makita1@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
Date: Fri, 4 Dec 2026 10:20:07 +0100 [thread overview]
Message-ID: <20261204092007.CKM9zFQP@linutronix.de> (raw)
In-Reply-To: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com>
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
prev parent reply other threads:[~2026-12-04 9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20261204092007.CKM9zFQP@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fcarli@gmail.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--cc=stable@vger.kernel.org \
--cc=toshiaki.makita1@gmail.com \
/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