From: Stephen Hemminger <stephen@networkplumber.org>
To: Scott Mitchell <scott.k.mitch1@gmail.com>
Cc: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com,
mb@smartsharesystems.com
Subject: Re: [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration
Date: Wed, 2 Dec 2026 16:00:01 -0800 [thread overview]
Message-ID: <20261202160001.72ed20ac@phoenix.local> (raw)
In-Reply-To: <20261202185420.17858-1-scott.k.mitch1@gmail.com>
On Wed, 2 Dec 2026 10:54:18 -0800
Scott Mitchell <scott.k.mitch1@gmail.com> wrote:
> Kick the af_packet Tx ring through an io_uring SQPOLL thread instead of
> sendto(), so the kernel's Tx processing runs on a kernel thread rather
> than the PMD lcore. Patch 1 adds common liburing detection, patch 2 uses
> it in af_packet.
>
> Depends-on: series-40243 ("net/af_packet fixes and Tx features")
>
> v3:
> * No longer an RFC: io_uring stays in af_packet. (Stephen)
> * New patch 1/2 detects liburing (>= 2.4) in config/meson.build and sets
> RTE_HAS_LIBURING. (Stephen)
> * Probe fails if tx_io_uring_enabled is set and io_uring can't be set
> up, instead of falling back to sendto(). (Stephen)
> * io_uring devargs are passed in one struct; __rte_unused replaces
> RTE_SET_USED(); shared_uring_rings needs no #ifdef; shorter logs.
> (Stephen)
> * A kick that finds the submission queue full falls back to sendto()
> instead of being dropped.
> * Probe fails if the kernel lacks IORING_OP_SEND (Linux 5.6), and
> IOSQE_CQE_SKIP_SUCCESS is used only where supported (5.17); before,
> every kick failed on older kernels and Tx stalled.
> * The kick runs on every non-empty burst; sendto() error accounting is
> unchanged.
> * Docs: tx_io_uring_q_cpu indexing with tx_io_uring_wq_num,
> sq_thread_idle=0, and Tx queue selection by the SQPOLL thread CPU.
> * Tests skip when io_uring SQPOLL is unavailable, check that the SQPOLL
> thread exists, wait long enough for it to sleep at HZ=100, and require
> stable thread counts; a new test checks that probe fails cleanly.
>
> Scott Mitchell (2):
> config: detect liburing
> net/af_packet: add iouring Tx acceleration
>
> app/test/test_pmd_af_packet.c | 391 ++++++++++++++++++++++
> config/meson.build | 6 +
> doc/guides/nics/af_packet.rst | 24 ++
> doc/guides/rel_notes/release_27_03.rst | 1 +
> drivers/net/af_packet/meson.build | 7 +
> drivers/net/af_packet/rte_eth_af_packet.c | 327 +++++++++++++++++-
> 6 files changed, 752 insertions(+), 4 deletions(-)
>
More verbose AI review.
I would split the driver change from the test changes for easier review.
Not sure about everything here:
Review: [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration
Series depends on series-40243, which is not in main (27.03-rc0,
ddb3b0c), so it was not applied or built. Reviewed from the diff
against the af_packet driver in main.
Summary
-------
No correctness errors found in the kick path: the SQ tail/NEED_WAKEUP
ordering, CQ sizing, CQE_SKIP gating and the SQ-full sendto() fallback
are right. Teardown order (ring exit before munmap) is right.
The tests are the blocker: four of the six new cases depend on
scraping /proc for a kernel thread name. That has to come out.
The rest is simplification and policy: the SQPOLL sharing
code carries state and a fallback it does not need, errors from the
async kick vanish from stats, devargs that cannot be honored are
accepted, and the performance claim has no numbers or CPU accounting.
Patch 1/2: config: detect liburing
----------------------------------
Info:
* liburing is a new optional dependency; add it to the optional
libraries list in doc/guides/linux_gsg/sys_reqs.rst.
* Commit message says 2.4 "provides the io_uring setup flags and
helpers af_packet needs". Everything used in 2/2 exists in 2.3
(SINGLE_ISSUER, FEAT_CQE_SKIP, sq.ring_entries). Either say which
2.4 symbol is needed or just say 2.4 is the tested minimum.
Patch 2/2: net/af_packet: add iouring Tx acceleration
-----------------------------------------------------
Error:
* The tests scrape /proc and key off a kernel thread name.
count_sqpoll_threads() walks /proc/self/task/*/comm and counts
entries starting with "iou-sqp-"; wait_sqpoll_threads() polls that
every 10 ms for up to a second waiting for five matching samples;
count_open_fds() walks /proc/self/fd. Four of the six new tests
pass or fail on the result. This cannot go in:
- A thread's comm is not ABI. It was the kthread "io_uring-sq"
(not a task of the process at all) before 5.12, so the tests
fail on 5.6-5.11, which the driver claims to support, and it
breaks again whenever the kernel renames it.
- The count is process wide. Any other io_uring user in
dpdk-test, or a thread left by an earlier test, changes the
answer.
- Thread creation and exit are asynchronous, so the result is
timing dependent; the "stable for 5 samples" loop is an
admission of that. This will be flaky on a loaded CI box.
- It tests the kernel, not the driver. Whether ATTACH_WQ shares
an SQPOLL thread is io_uring's business.
Remove count_sqpoll_threads(), wait_sqpoll_threads(),
check_sqpoll_active(), count_open_fds() and the asserts built on
them. Test what the driver does through its own interface:
- io_uring_tx, idle_wakeup: frames arrive on the tap. That is
already checked and is sufficient.
- shared_sqpoll: create the port with wq_num 1 and 2, send on
every queue, check the frames arrive.
- setup_fails: probe returns an error. Nothing more.
- create_destroy: the loop itself is the test; if an fd check is
wanted, compare the fd returned by open("/dev/null") before
and after instead of listing /proc/self/fd.
io_uring_sqpoll_testable() (a plain io_uring_setup() probe) is
fine to keep as the skip condition.
Warning:
* shared_uring_rings is unnecessary. Queues are set up in order and
any failure is fatal, so the group leader for queue q is always
queue (q % wq_num). That removes the rte_calloc_socket() of CPU-only
bookkeeping, both rte_free() calls, the two pmd_internals members
and af_packet_io_uring_share_init():
if (args->wq_num != 0 && q >= args->wq_num) {
leader = &internals->tx_queue[q % args->wq_num];
params.flags |= IORING_SETUP_ATTACH_WQ;
params.wq_fd = leader->uring_ring.ring_fd;
} else {
/* own thread, optional SQ_AFF */
}
The "needs liburing" error then moves to the top of
af_packet_io_uring_tx_queue_init(), which today returns -ENOTSUP
with no message.
* ATTACH_WQ failure falls back to a private SQPOLL thread with a
NOTICE. v3 made setup failure fatal; this is the same class of
silent fallback. The fallback also pins the extra thread to the
group's CPU (cpu_idx == ring_idx), so two SQPOLL threads busy-poll
on one core. Fail the probe.
* Devargs that cannot be honored must fail at probe, not warn or be
ignored:
- tx_io_uring_q_cpu count > tx_io_uring_wq_num: WARNING only
- tx_io_uring_q_cpu count > qpairs (no wq_num): silent
- tx_io_uring_wq_num > qpairs: silent, no sharing
- any tx_io_uring_* option with tx_io_uring_enabled=0: silent
rte_pmd_init_internals() has nb_queues; check there and return an
error.
* Async kick errors are dropped. eth_af_packet_tx_kick() discards
CQEs with io_uring_cq_advance() without reading cqe->res, so with
the interface down (ENETDOWN/ENXIO) tx_pkts keeps counting and
err_pkts stays 0, where the sendto() path zeroes num_tx. The CQ is
drained there anyway; look at the results:
io_uring_for_each_cqe(ring, head, cqe) {
if (cqe->res < 0 && cqe->res != -EAGAIN &&
cqe->res != -ENOBUFS)
pkt_q->err_pkts++;
n++;
}
io_uring_cq_advance(ring, n);
A count of failed kicks is not a packet count, but it makes a dead
Tx path visible. Document the difference.
* IORING_SETUP_SINGLE_ISSUER: what does it buy with SQPOLL? The SQ
thread is the only issuer regardless, and DEFER_TASKRUN is not
used. It costs the af_packet_io_uring_init() retry wrapper for
pre-6.0 kernels, is set on thread owners but not on attached rings,
and makes io_uring_unregister_files() return -EEXIST when
eth_dev_close() runs on a thread other than the one that probed.
Drop the flag and the wrapper.
* io_uring_unregister_files() before io_uring_queue_exit() is
redundant in both eth_dev_close() and the probe error path; closing
the ring releases the registered file. Return value is ignored
anyway. Remove both calls.
* The new parameter dump is PMD_LOG(INFO) and unconditional. The
lines above it are DEBUG. Five or more INFO lines per port for a
feature that is off by default is noise; use DEBUG and print only
when enabled.
* drivers/net/af_packet/meson.build: "deps += ['ethdev']" is
redundant, ethdev is in std_deps (drivers/net/meson.build). Drop.
* Commit message: "improves throughput by 30%+" has no test setup
(packet size, queues, kernel, qdisc_bypass) and no CPU accounting.
The SQPOLL thread spins for sq_thread_idle (default 500 ms) after
every kick, so under load this is one more busy CPU per SQPOLL
thread. The fair baseline is sendto() with the same number of
cores. Say so in the commit message, and state the CPU cost in
af_packet.rst; the doc only mentions pinning for RT lcores.
Info:
* Five devargs is a lot of surface. tx_io_uring_sq_size: one SQE per
burst and a full SQ already falls back to sendto(); is there a case
where the user must tune this? If not, make it a constant.
tx_io_uring_wq_num is the number of SQPOLL threads but is named
after the ATTACH_WQ flag; tx_io_uring_threads would say what it is.
* kq_cores[RTE_MAX_QUEUES_PER_PORT] puts 4 KB on the stack in
rte_eth_from_packet() and the name does not match the devarg
(q_cpu). ETH_AF_PACKET_TX_IO_URING_Q_CPU and _WQ_NUM lack the _ARG
suffix the other keys have.
* struct pkt_tx_queue: struct io_uring (about 200 bytes) sits between
framenum and the stats counters, so the sendto() path now spans
more cache lines. Put the uring members after the counters.
* af_packet_io_uring_tx_queue_init() mixes declarations after
statements inside #ifdef. Simpler to compile the whole function
under RTE_HAS_LIBURING with a stub that logs and returns -ENOTSUP
otherwise. "attach" also tests ring_idx < q, which the non-NULL
leader check already implies.
* uring_ring.sq.ring_entries reaches into liburing internals on the
fast path; keep the SQ size in pkt_tx_queue.
* af_packet.rst: "the CPU it runs on selects the interface Tx queue"
is true when XPS is configured; without it the queue comes from the
skb hash / ndo_select_queue. Qualify the statement. New list items
should end with ";" like the existing ones.
* test_pmd_af_packet.c: the "Test: TX with io_uring kicks" comment is
stranded above test_af_packet_io_uring_setup_fails(); move it down
to test_af_packet_io_uring_tx().
* Subject says "iouring"; cover letter, docs and devargs say
"io_uring".
next prev parent reply other threads:[~2026-12-03 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
2026-02-04 16:52 ` Stephen Hemminger
2026-02-05 0:08 ` Scott Mitchell
2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
2026-12-01 22:44 ` Scott Mitchell
2026-12-02 17:16 ` Stephen Hemminger
2026-12-02 18:52 ` Scott Mitchell
2026-12-02 18:54 ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
2026-12-02 18:54 ` [PATCH v3 1/2] config: detect liburing Scott Mitchell
2026-12-02 18:54 ` [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration Scott Mitchell
2026-12-02 23:43 ` Stephen Hemminger
2026-12-03 0:00 ` Stephen Hemminger [this message]
2026-12-02 16:59 ` [RFC v1] net/af_packet: add io_uring TX acceleration Stephen Hemminger
2026-12-02 17:02 ` Stephen Hemminger
2026-12-02 17:03 ` Stephen Hemminger
2026-12-02 17:04 ` Stephen Hemminger
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=20261202160001.72ed20ac@phoenix.local \
--to=stephen@networkplumber.org \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=scott.k.mitch1@gmail.com \
--cc=thomas@monjalon.net \
/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.