[RFC net v2 0/2] af_packet: retire TPACKET_V3 blocks without waiting for copiers
flat view
HOTtoday
From: Jingxuan Xie <hidden>
Date: 2026-10-30 08:15:21
Also in:
linux-rt-devel, lkml
Subsystem:
networking [general], packet sockets, the rest · Maintainers:
"David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Linus Torvalds
This revision keeps asynchronous block retirement but removes completion-side queue locking, the four-state enum, the eight-block publication budget and the workqueue used in v1. Private copy accounting now lives in the existing pgv allocation. Packet allocation and the existing retirement timer publish ready blocks in order under their existing receive queue lock. A preempted copier in a sealed block does not prevent capture into the next available block. Copy completion only performs a release decrement. In the absence of further traffic, publication may wait for a later timer callback; there is no hard bound under RT starvation. A finite ring can still exhaust. Patch 1 independently moves virtio RX-header preparation ahead of frame reservation. Patch 2 implements the retirement change. Neither patch changes the mmap layout or adds a UAPI. Changes since v1, in response to Willem de Bruijn: - Split virtio header preparation into its own patch. - Remove the second receive queue lock acquisition from copy completion. - Remove the state enum, separate metadata allocation and worker lifecycle. - Replace the fixed publication budget with a loop over existing ready blocks. - Use release completion and acquire observation of per-block counts. - Permit idle delivery to wait for the existing retirement timer. Testing: ARM64 QEMU virt, four CPUs, PREEMPT_RT and lockdep. The unmodified retirement logic blocks sender B behind a deliberately delayed copier A. With v2, B completes capture before A is released, for full-block and timer retirement; idle delivery, block sequence, lengths and payload are checked. The delay is introduced by validation-only kernel instrumentation and is not included in this series. Ordinary psock_tpacket and psock_fanout pass on uninstrumented RT and non-RT builds. External validation tests exercise the actual private helpers; LKMM tests check multi-copier ordering. The ready-block loop has no fixed work budget: a large ready backlog can lengthen the receive queue critical section. A validation case publishes 1000 blocks in one call. This tradeoff is explicitly retained for review. Separate RT KASAN and strict KCSAN runs pass the helper checks, psock tests, delayed-copy tests and concurrent-close test without sanitizer reports. Patch 1 also passes an independent malformed-GSO runtime check. ARM64 W=1 packet-object builds pass for each patch and under allyesconfig/allmodconfig. QEMU does not establish hardware NIC or Orin integration acceptance. v1: https://lore.kernel.org/netdev/20261028070528.139531-1-jingxuanxie@deeproute.ai/ (local) Review: https://lore.kernel.org/netdev/willemdebruijn.kernel.31ae9fde05c@gmail.com/ (local) Base: fcc00b15cb21a6de76826e5012b2c758505f5e65 (net/main). jingxuanxie (2): af_packet: prepare the virtio header before reserving an RX frame af_packet: retire TPACKET_V3 blocks without waiting for copiers net/packet/af_packet.c | 162 +++++++++++++++++++++---------------------- net/packet/internal.h | 9 ++- 2 files changed, 88 insertions(+), 83 deletions(-) base-commit: fcc00b15cb21a6de76826e5012b2c758505f5e65 -- 2.25.1