Article View: linux.kernel.netdev
Article #8369Re: [RFC net 1/2] af_packet: retire TPACKET_V3 blocks without waiting for copiers
From: Willem de Bruijn
Date: Wed, 28 Oct 2026 21:42
Date: Wed, 28 Oct 2026 21:42
64 lines
14173 bytes
14173 bytes
Jingxuan Xie wrote:
> From: jingxuanxie <jingxuanxie@deeproute.ai>
>
> TPACKET_V3 waits for a ring-wide read lock before retiring a block,
> while holding sk_receive_queue.lock. A copier keeps the read lock
> after reserving a frame and dropping the queue lock. On PREEMPT_RT,
> preempting that copier can therefore delay another packet path or
> the retirement timer until the copier runs again.
>
> This was investigated after an approximately 355 ms block-retirement
> wait in a real PREEMPT_RT deployment. A QEMU ARM64 SMP PREEMPT_RT
> reproducer uses test-only instrumentation to delay one outgoing
> copier after reservation, with a second sender forcing retirement.
> The unmodified retirement logic blocks the second sender. The
> instrumentation is not part of this series.
>
> Track FREE, ACTIVE, SEALED and USER state per block in private
> metadata. Reserve and complete copies under the receive queue lock,
> retaining the original block reference across the unlocked copy.
> Seal a full or expired block and try the immediately following block
> without waiting. Publish sealed blocks in reservation order once
> their copies have completed. Do not reuse a sealed block merely
> because its mmap status still reads TP_STATUS_KERNEL.
>
> Limit each locked publication batch to eight blocks and continue
> ready backlogs on an unbound worker. Stop the timer and worker before
> freeing metadata. Check readiness using the last published block,
> and validate virtio headers before reserving a frame so an invalid
> header cannot strand an unfinished reservation.
>
> Tested against that reproducer with both full-block and timer
> retirement: B completes while A remains delayed, blocks are not
> published early, and sequence numbers, lengths and payload match.
> An uninstrumented QEMU guest also passes psock_tpacket and
> psock_fanout. The accompanying KUnit suite covers the state helpers.
>
> Keep the mmap layout and userspace status protocol unchanged. Ring
> exhaustion can still drop capture copies; a stalled copier no longer
> has to block retirement or copying into another available block.
>
> The block producer index must cover the full unsigned block count,
> matching the independent publication index across large rings.
>
> Assisted-by: LLM
> Fixes: 632ca50f2cbd ("af_packet: TPACKET_V3: replace busy-wait loop")
> Signed-off-by: Jingxuan Xie <jingxuanxie@deeproute.ai>
> ---
> net/packet/af_packet.c | 319 +++++++++++++++++++++++++----------------
> net/packet/internal.h | 27 +++-
This is a huge change. Try to solve the problem with a minimal fix.
The patch is doing more in one patch than needed. Such as moving when
virtio_net_hdr_to_skb is called. Probably for good reason but then that is
a separate change.
The main purpose can hopefully be achieved with less code churn too.
Try to avoid re-acquiring sk_receive_queue.lock, a regression. Batching
adds complexity and is probably not needed. system_dfl_wq runs as
SCHED_NORMAL, so this may introduce a new priority inversion.
Also: whitespace corruption, a confidential ("top secret") footer.
Technical Details
Message-ID:
<willemdebruijn.kernel.31ae9fde05c@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353046-linux-kernel-netdev=dewy.ruReferences:
<20261028070528.139531-1-jingxuanxie@deeproute.ai> <20261028070528.139531-2-jingxuanxie@deeproute.ai>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353046-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [RFC net 1/2] af_packet: retire TPACKET_V3 blocks without waiting
for copiers
Date: Wed, 28 Oct 2026 17:42:14 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.31ae9fde05c@gmail.com>
References: <20261028070528.139531-1-jingxuanxie@deeproute.ai>
<20261028070528.139531-2-jingxuanxie@deeproute.ai>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="1875860"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6cL8+x39hUKt7bgBV8czOfCdqFg= sha256:dMOA1hVS7cm9doCQL+6qRmQ+NkvOltuHrMrUt96kFd0=
sha1:7JRpuHkWJtiCWn40cGjAODtJZfw= sha256:hrgL3Np7cZe+txG4L8CEP/hZvqy8UqOx9jLlVjm6BpE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id BDE46125C4D; Thu, 29 Oct 2026 00:42:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id bhhhWMOdqh7K;
Thu, 29 Oct 2026 00:42:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-353046-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 56E44125C4B; Thu, 29 Oct 2026 00:42:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 769E8601E65; Wed, 28 Oct 2026 21:42:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793223737;
b=rbNW+1T9/xLZqIIdaL94nbo07M69uefTnfl7O+EABfVYTVgBsekPBvy/ZkbLXucl8BeA
cIiSsTP+bEgdtMYFmAf9zi48AYXPy7DeqCQaPKQNfxSqrN09jSBzLLRs7/CUUrLI3UpNt
eXWsKXmnjZTuGiyfY/C/E3jRfDJm6VUDNqn4QSfcPRxetCawg+ztaT63nTmd4UYeCcHsY
J1Qh6S9t+n98XPGb4F83YbJhnuGi2JwjqJSC/qfJbLMxRf9xg7f6yqzKQTzcZKYt78WUe
CjPjkaQejFwLtbByC+JrKMl4KbwVyL8e7rMGe3HdBy/G2tCEKmmfoCzIyzqA+JLyRQw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793223737;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Message-ID:In-Reply-To:
References:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Type:Content-Transfer-Encoding;
bh=97MNXpQUpTND+mmD0eYg+NTUf+Ug+pSsdYCeQhUXxgU=;
b=3KgkkCujIYjzabAGSk7G95KkItW1GQI7AtJS2kkC3yX8UlOLcNt6RrOlvHyefyAT6E5Y
zOYpom6FZHEQD8lrV0x1LT/ek8RoUCRkk/xPUQ3Dz7LYkUiY4Q6LjQCw3G4OQ5WWfHmmI
ars5ntxc3FZaXCbjyUA5Vtd9+rOk4feXREv0wVR/Vk5e8JJF+w4ldMglJyL6h4PCsJVOl
GlQ9iwKFBpejeHEACoXsDV45wcdJvWuI3cUNRvW/6aQFg9YbHKLAGpXZQT/c4c57IgDhi
fp/9jvBR+nU2/cbsADp9fhVRGnh8MfeQJ+UYZ639EFPKgMn4bRSmccEI0Vp47KC2IWg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EJ084YdX;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B677606A322;
Wed, 28 Oct 2026 21:42:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EJ084YdX
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.172
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793223736;
b=jkfK1N3Ptgb1K6TMmPa08NCkUbAfSNJljizIXdobRnMuh9/QvJzKVie/QWnhu+n5ACDb
+Oc+cWrJRSGFwhR7JCZRsk5SM6OPyooqztTb9v02zOzPjQf3TPEu/AoBr5jTUhDibs3ch
1+AkJHamkg7Bf4FPpXZKZ9QYWu9+vVu+qxaAWmMbyvo9U/fOnqJfxs/ieuKARPcnPzn95
VqHY1fzdokW2s69cFEcFAU24btbk+noZgzv2OLoZ/jd3z+5cPpJ5D1NeE4UqZQ3CSkdZc
u9XH+QrNBqCOyY6oLrjdMp6CQ8Caded/R0KyBHh/E19TvdGS42fvAZZ6on2nY2D2pAg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793223736;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=97MNXpQUpTND+mmD0eYg+NTUf+Ug+pSsdYCeQhUXxgU=;
b=gHe/zSsIH3WsMEf4OXxqJplPlLQb1mzyCtAlU+CwdQ1CfDSKqqoT03DUxbYbRqUyl//Z
/I8GnGSM5u3Y2VLHUzEd1awn4rKw4Ppxh95ckl19Wjntwcg7viTZRjSZNflx4Y28N3F1M
gYSlln2hmlhNx67jEAMkMaMAe0MpgBf0V0GH4tOJJeLIWz5F8LoIK7vkHaqGZQW6i92jw
P0qKHj7MhnbRVLr7k1OJWFxpKUbu4oN4hc0X73/supBrNt8sltC2B+nwDExC5QoLzceeD
NO2KovQvqOZqI3MqyhJGEEgMbzhXW10IUVTfM2y91B04CDhyJIQBXDlLvQguMtXhgpg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EJ084YdX;
arc=none smtp.remote-ip=209.85.221.172
X-Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64B9B606A31E
for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 21:42:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 64B9B606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-5e9528732b4so1213888e0c.0
for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 14:42:16 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793223735; x=1793828535; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=97MNXpQUpTND+mmD0eYg+NTUf+Ug+pSsdYCeQhUXxgU=;
b=EJ084YdXc2eiS3ZS+k8TSpmIQcLIf9JfhMiwssAV8dPSeFYAeOjGUHYN56I9QjgZ/K
OWFgeZP0q5kSQwwQUaF2MZeR3/X7m58czhqSFPm/O7fmhF0tR9fXsfoBCU6Ovzlx15i4
9IW5mtY20o4p7Gd5vv9OiL8SyX2Ve2MgKsp4P6mnYAWQFC/bEdLrjmG+vS/5Rpvrt8yF
HzKtuCZYpI2UYB+jE3tUbyS5VVcsL82gI7CsfoPsIfXlhnC77CAcVu5KajAU+JZ4+dVY
wIKIMlZtbsOktiBSbwbNuYJ3Tlr5dK/k47aGzIOypKqd+mI1nYUdz3tsdiRP42HaouQ8
3nnQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793223735; x=1793828535;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=97MNXpQUpTND+mmD0eYg+NTUf+Ug+pSsdYCeQhUXxgU=;
b=OfuqEsj0MqVUbN6ukcWl9QDcx8PZU9Z6gVIDJ9UkM1HvjD8ufxxwqFG48IWm5hhbnY
57GZckDhM+RuBZe2rmYmXOayEYn1EuTgSrjAn3ZkqN/czKLsU9Yii8hHeqKvD9P4U+Bs
t8FZ30WRnlsRDAcxXRxsLVG1eI11Cpri3Ceu10BPFSYKqzpQp3ozUgqGWiyML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Mw/SV3PffJXOO4EpkAIsNh3MtogBeb8FP8B6BB7bE0uxini2DWQKxyiwRFhMIVE
X-Received: by 2002:a05:6102:2c81:b0:7c2:7a0:ae28 with SMTP id ada2fe7eead31-7d03a55fdaemr1975911137.30.1793223735408;
Wed, 28 Oct 2026 14:42:15 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-99125932041sm7264854241.1.2026.10.28.14.42.14
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 28 Oct 2026 14:42:14 -0700 (PDT)
X-Cc: willemdebruijn.kernel@gmail.com,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org
X-In-Reply-To: <20261028070528.139531-2-jingxuanxie@deeproute.ai>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list