From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1B34606A322 for ; Thu, 3 Dec 2026 00:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=rfHlCVdj Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87BEA402A7; Thu, 3 Dec 2026 01:00:08 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTPS id 401374028B for ; Thu, 3 Dec 2026 01:00:07 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3b41e5a1719so5764613a91.3 for ; Wed, 02 Dec 2026 16:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796256005; x=1796860805; darn=dpdk.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dXjjCUKKxIUaRrV3BMMYiKpOdovGMxfjfBx6GbIBiRY=; b=rfHlCVdjjxqbS5IX9TDpAk3+eYNnwsUF3n8al+fG0CNTEPDxHA67LHhcqEJGiv0kGM zOxQ4HqKpEfXwy2E1h8+25LpgMCkjC388WEJbrn/TJ5w0miB5CTNeUlk0qrWrwm+psaI ex9vyRNFK+BWKrMLgl6WSF/7Y2lru7y2RReX7YIgUUeYDsrP9/a5pWkbS2pciVXMTCRF j+LBhJxu4BfEKjfW7cfooDF059fzaVJJvCM7H/hY0NoHjfpVS5l1WLX4RTjTRMNtHkCQ EdGZt6QquGm6MSpm6/01FyT96u8xAnmGyY/6QVDjim5oDtdQ6NyD2geOS/+x88GcDJTt C3ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796256005; x=1796860805; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dXjjCUKKxIUaRrV3BMMYiKpOdovGMxfjfBx6GbIBiRY=; b=jyhH9E6+57+R/N/otJ0ks9+Nerr/CJHTN8BFDRelw60qiQEVGyH6TdHyGAH1aaMETW QeVH+2C9Vyk5U9OFDTZAYy+gq6pN8npSu+IkZUnobLL16CmzHMzmRtEGDrciQpKmWTT2 9hUkggxxGKL76LGQlBVce5wppi7PpGoYfqUNeWiOY1S2E0uJqN9Gj+syijOeE87sOf3p CXEMGtWBBdYvUtCuW5agl91vkFXFQAuyuushlhMnwwzFDbr6FGhEaFMAJdOOhsZttWii bRRQSf+9sOBrqt9yuEeC2/dwrXdpZmwn5mHThFs/SOXBnxVdX85u0dEH0Xe/6ibVhSY1 lszQ== X-Gm-Message-State: APuU4Z9eEJacNAO43ETITB50tgY8tWDVGm7YDYnrlhqC9zULFm1q4BDk yIcKrmqvuEUTEscjRwnUFHDUpYR7rZaAzprZnTL5MW6A1arDavM1sCWpxtHfbUtRJSo= X-Gm-Gg: AZFdTZdtiQNHZ5nuuaxPTA2YQ30+yrf/4IW+lJNtoCUxNSfc0jaimKkrF9cMPb6kcgq 7fJGA8o4WDlPIJY6XQHaInFuzkUdhsYFtD4IaRscqOKdnZtohOzf6ZrLkkM0La389qqxhNEJtCH DTMe7+jLagY6SRCRl2UV87f1+tFvLjNxI7l4pRoaQksHHZ25ZsMEWWOi9FzmqGLBQikFmFzludP 2ugQ7sPP1pxFEGcj3lwkfejxykhUskirZqvTwwY977C/bZOVGT01qmtY3Hca8ykEwlp0Xky0otU 2MGrBUwG6K2U/y7fV2Ip6rI+9i/jXddTVOn9281ITAORmeFdPOV53dsZFZbVYDS+aS9ncqQbzGm kmJUPQnflqnKd5n+3yp/Zi0IcB4cSRAVYOE46lHHzIyYegx4yqSiREcL9YjLiaVnAxGr44KaLmt IVihxF61OfNWLAZ9X8mnHDL+S9V8Lf7q9n+kYH0n/7rF+dqWHfwx5qNLJHksDdLIrUAMoLwTT97 mJJEE/iRIJpqqbJUD4ooDqNVMq2zYLrpL6p0vsVSMryVE0LYra3Dc+z0bUzTcMl8Xs1dgXgTh0S 21PAogca7TpT3TCBtFQ+EDkNCkcuv1Gjfc4TeQu7NPciEupEVnRFah4PRl81DvuZ+tGNGg== X-Received: by 2002:a17:90b:2ecb:b0:3b0:accf:5c66 with SMTP id 98e67ed59e1d1-3b41c989fecmr37969344a91.49.1796256003828; Wed, 02 Dec 2026 16:00:03 -0800 (PST) Received: from phoenix.local (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b50234fb25sm17673172a91.2.2026.12.02.16.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 16:00:03 -0800 (PST) Date: Wed, 2 Dec 2026 16:00:01 -0800 From: Stephen Hemminger To: Scott Mitchell 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 Message-ID: <20261202160001.72ed20ac@phoenix.local> In-Reply-To: <20261202185420.17858-1-scott.k.mitch1@gmail.com> References: <20261201223626.97745-1-scott.k.mitch1@gmail.com> <20261202185420.17858-1-scott.k.mitch1@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, 2 Dec 2026 10:54:18 -0800 Scott Mitchell 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".