All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC net 0/2] af_packet: asynchronous TPACKET_V3 block retirement
@ 2026-10-28  7:05 Jingxuan Xie
  2026-10-28  7:05 ` [RFC net 1/2] af_packet: retire TPACKET_V3 blocks without waiting for copiers Jingxuan Xie
  2026-10-28  7:05 ` [RFC net 2/2] af_packet: add KUnit coverage for asynchronous V3 retirement Jingxuan Xie
  0 siblings, 2 replies; 4+ messages in thread
From: Jingxuan Xie @ 2026-10-28  7:05 UTC (permalink / raw)
  To: netdev; +Cc: willemdebruijn.kernel, davem, edumazet, kuba, pabeni, horms

TPACKET_V3 currently serializes block retirement against payload copies
using a ring-wide read/write lock. The retiring path also holds the
receive queue lock. An unfinished copier can therefore delay unrelated
packet work and the timer, particularly on PREEMPT_RT.

This RFC separates sealing from publishing. At most one block is ACTIVE;
several may be SEALED while their copiers finish. Copy completion retains
its original block, and publication advances strictly in ring order. A
producer only tries the next block and drops capture copies when that
block cannot be reused. The mmap ABI remains unchanged.

The first patch implements this state machine. The second adds KUnit
tests of the actual private helpers. Test-only delay instrumentation is
excluded from both patches.

This is offered for design review, especially:

* Whether maintaining ordered publication of sealed blocks is acceptable.
* Whether eight-block batches plus system_dfl_wq are appropriate for
  a completed backlog. Each batch releases the receive queue lock.
* Whether the private metadata cost (24 bytes/block on ARM64) and the
  extra completion lock acquisition are acceptable.

Discovery and validation:

* Investigation started with an approximately 355 ms retirement wait in
  a real PREEMPT_RT deployment. The trace alone does not establish the
  identity or full duration of a task preempting the copier.
* A test-only hook in QEMU delays copier A after its frame reservation.
  A second CPU sends B, and another RT task adds load on A's CPU. The
  baseline blocks B until A is released. With this series, B returns
  while A remains delayed, for both full-block and timer retirement.
  Checks of ordered sequence numbers, packet lengths and payload pass;
  neither A nor B is published before A completes.
* An uninstrumented QEMU ARM64 virt guest with four CPUs, PREEMPT_RT,
  lockdep and virtio-net passes all 17 packet-prb KUnit cases, plus
  psock_tpacket and psock_fanout. The injected comparison uses loopback
  with an outgoing-only capture filter to avoid a shared NIC TX lock
  confounding packet-socket synchronization.
* W=1 af_packet.o builds pass with ARM64 allyesconfig and allmodconfig.
  Complete builds fail in unchanged ARM64 syscall-table initialization;
  allyesconfig also fails in lockdep formatting with GCC 13 and
  CONFIG_WERROR. The errors also
  reproduce on the same net baseline; full builds are not claimed as
  passing.

Hardware integration, performance overhead, KASAN and KCSAN validation
are outstanding. QEMU results describe generic packet-socket/RT tests,
not hardware validation. Finite capture capacity remains a limitation:
this design avoids waiting for a stalled copier, not capture loss.

An LLM assisted with analysis, implementation, tests and writing. The
technical request was to replace synchronous retirement with per-block
copy accounting, preserve the UAPI and publish completed blocks in order.

Base: f75062536e2d45ee182828f0e47e0124be2fdc8d (net)


jingxuanxie (2):
  af_packet: retire TPACKET_V3 blocks without waiting for copiers
  af_packet: add KUnit coverage for asynchronous V3 retirement

 net/packet/.kunitconfig     |  10 +
 net/packet/Kconfig          |   9 +
 net/packet/af_packet.c      | 323 +++++++++++-------
 net/packet/af_packet_test.c | 649 ++++++++++++++++++++++++++++++++++++
 net/packet/internal.h       |  27 +-
 5 files changed, 893 insertions(+), 125 deletions(-)
 create mode 100644 net/packet/.kunitconfig
 create mode 100644 net/packet/af_packet_test.c


base-commit: f75062536e2d45ee182828f0e47e0124be2fdc8d
--
2.25.1

________________________________


本电子邮件及转载的任何文件都属绝密文件,并且仅供标明地址的个人或团体使用。如果您收到的电子邮件存在错误,请通知本公司,删除全部原始信息(包括任何原始信息的备份),并且禁止散布或分发全部或部分原始信息。本公司不担保本电子邮件中信息的准确性、适当性或完整性,并且对此产生的任何错误或疏忽不承担任何责任。在正式协议签订以前,这里提到的任何参考术语、与主题相关的情形以及随后的电子邮件中的谈判,都将严格“遵守合同”。接收方应在接收电子邮件或任何附件时检查有无病毒,本公司对由于转载本电子邮件而引发病毒产生的任何损坏不承担任何责任。


Reproduced in this e-mail and any files are considered top-secret documents, and only indicate the address of individuals or groups. If you receive an e-mail there is an error, please notify the Company, delete all the original information (including any backup of the original information), and the prohibition of the dissemination or distribution of all or part of the original information. The Company does not guarantee the accuracy of the information in this e-mail, adequacy, or completeness, and this produces any error or omission does not bear any responsibility. The formal agreement was signed prior to any reference to the term mentioned here, and the circumstances relevant to the subject and subsequent e-mail in the negotiations will be strictly "comply with the contract." The receiver should be receiving an e-mail or any attachment, check for viruses. The company reproduced this e-mail because of the virus caused any damage resulting from not bear any responsibility.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-28 21:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28  7:05 [RFC net 0/2] af_packet: asynchronous TPACKET_V3 block retirement Jingxuan Xie
2026-10-28  7:05 ` [RFC net 1/2] af_packet: retire TPACKET_V3 blocks without waiting for copiers Jingxuan Xie
2026-10-28 21:42   ` Willem de Bruijn
2026-10-28  7:05 ` [RFC net 2/2] af_packet: add KUnit coverage for asynchronous V3 retirement Jingxuan Xie

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.