Article View: linux.kernel.netdev
Article #14076Re: [PATCH net v4] af_packet: avoid waiting for TPACKET_V3 copies at retirement
From: Willem de Bruijn
Date: Tue, 10 Nov 2026 17:17
Date: Tue, 10 Nov 2026 17:17
47 lines
13598 bytes
13598 bytes
Jingxuan Xie wrote:
> TPACKET_V3 retires a full or expired block while holding
> sk_receive_queue.lock. prb_retire_current_block() takes
> blk_fill_in_prog_lock for write to wait for in-flight skb_copy_bits()
> before publishing the block.
>
> On PREEMPT_RT a read lock can be held by a task that has been
> preempted or is running on another CPU. The packet path or the
> retirement timer then blocks on the write lock while holding
> sk_receive_queue.lock, and the receive path resumes only after the
> copy completes. This was observed as a receive stall of hundreds of
> milliseconds in a PREEMPT_RT deployment; manual inspection found the
> same unconditional write_lock() in both the full-block and the timer
> retirement paths.
>
> Try to take the write lock without blocking on PREEMPT_RT. If a copy
> is still in progress, leave the current block and its metadata
> untouched:
>
> - the retirement timer re-arms itself and retries after the configured
> interval;
>
> - packet allocation returns NULL, so tpacket_rcv() drops this capture
> record and accounts it in tp_drops, while the original packet remains
> in the network stack;
>
> - a later packet can retire the block once the copier has finished.
>
> Do not dispatch the next block while the current block is still open.
> The existing lock order and completion ordering are preserved, and no
> new state or worker is introduced. The trade-off is a higher capture
> drop rate while a copy is in progress; original traffic is unaffected.
>
> Non-PREEMPT_RT kernels keep the unconditional write_lock(): there
> read_lock() disables preemption, so the writer only waits for the copy
> to finish, not for a scheduled-out task to run again.
>
> The stall was reproduced on QEMU arm64 SMP PREEMPT_RT by delaying a
> copier after frame reservation: without this change the next sender
> blocks until the copier is released, with this change only that
> capture record is dropped.
>
> Fixes: 632ca50f2cbd ("af_packet: TPACKET_V3: replace busy-wait loop")
> Signed-off-by: Jingxuan Xie <jingxuanxie@deeproute.ai>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Technical Details
Message-ID:
<willemdebruijn.kernel.33a00c75cd53e@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360462-linux-kernel-netdev=dewy.ruReferences:
<20261110072221.24701-1-jingxuanxie@deeproute.ai>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360462-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4] af_packet: avoid waiting for TPACKET_V3 copies at
retirement
Date: Tue, 10 Nov 2026 12:17:19 -0500
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.33a00c75cd53e@gmail.com>
References: <20261110072221.24701-1-jingxuanxie@deeproute.ai>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="664208"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TFq2mJ9QOEXY9ZxcUMsCwXoaln8= sha256:vKe8UFt/aGcTcXKcbeBP44DfdN4VpmnD+QRbRWEjJKk=
sha1:KWWz+ZRczzBmuLSIHnld5dJkU10= sha256:1o/2oEygykWBQm8gGf2zA9eZv4rNZhlxpJR5w6d/sIM=
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 87E4F113C90; Tue, 10 Nov 2026 20:47:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, 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.249,
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 91sAPAaVVjNP;
Tue, 10 Nov 2026 20:47:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360462-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 72F45113C8C; Tue, 10 Nov 2026 20:47:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 6543D1266CC; Tue, 10 Nov 2026 17:17:25 +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=1794331043;
b=SXkvwqfT9udBpK7HUfH0v86PTvqWYDlTU3xrJ4bnMmdULFypFih0GaHySHtSbWdUnBx2
fY+tiDDdHyZRbj5nzXPsgIXymaTcq2LlMinWGgIQk+iZngl+pSpE2iMZGfXAakSXa2yW7
H7ao8Ncec4owYsdqJqvtwoZ6JpogiUO/g9RIUTE4gtFRfd/bbwbLIK5ZypQS51Yn+TnYL
zmpOxLmsVIuVh2JO9VW0gEAJExWgMgFRqE1EjvQ4Q/oydNxLmexQVxGTi+hugybiKFuwc
JVYuRDy6/CDAZaRTsd2bukbPC7icA+076XRrP2YyRzerdGGBBRpOiNLzt4v3w+/rwqQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794331043;
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=anu/2F6mroicCWt3l+8C2jxZSamPe+b0q+OPEpgFtcQ=;
b=T5QDte5Q96K+9mYSQeU7xF+73553K0Jlbzp7oVD3e+97LFdFwlKLIisKzuquK3Eq81s4
VsSn8xGHG/r8vnV+9DgruczoMJ0Y1UmpX5PHgtcqwoy9d3tqtsY0sQyZ232wB64NZJR14
0ErEioYxYj4MAsJN2/qRffSw9+MNRZ0fO9RLSOY2fEzCSxWdSFnzTUvUUYyVuYPXHk42s
pKwMbuXNF1oaNk1ruvDcQK5m4O5ASM6ksS0KMltBBPm77AHcbkg/EObd2QhhxsTdTrELd
tVBH0hJvgbeHwaf9pCeQHDibZHoipgfiLOxXLvUMroYeIFA+8lU3TfdduV1LogGQEow==
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=NKKCrJA9;
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 2B338606A333;
Tue, 10 Nov 2026 17:17:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NKKCrJA9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.173
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794331042;
b=TbMJo0CVEDCVyCyDz6hLHOOI403OE/mxORPlHFLjvEL8Cuv945Ufj28VR3oH/6Dv4a99
1FG2CoNdrSvCr9GNodkzQWT61ldYpPkAgybqxSU9zVAaODweJRkMQD/NQhJkc+Ig/md26
k+w7rGTSWKZacOPR2hP/jeI7Jq+egZpJLt9Ep6lRGd5vstFOAb1Ssb5MqelZpfBC+3nJl
dhta4Ou92O8CJyP91y+JjCq8h4kxlhnWfurFk+sgL1QY0JIBahgA9gVe1MDYjQb6gEbrm
ERDSooogBdAzYc9Al+5EpZKB7yVLqqhDEWHqE86K9LKefyvM52szuxSiG4kKxBBI5QA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794331042;
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=anu/2F6mroicCWt3l+8C2jxZSamPe+b0q+OPEpgFtcQ=;
b=vmIaOIpEFH3ExHXhVPCPPDDQOG1NhOY1a3ZeJNp9MbwuPOMqpMoO+YmEVaTybIf7MPAT
G9VISL81buAUcHEmjcHF/GmmYoA0GLum4FZPGAx1/LThbJ3qFROOAjEROGiC9dl7KTNL9
2Cy6wE1qaxwcOEOtkZwkqc20nEO5MOz2PYT55u4o8j65p18zN+A3ai+y7ocqstkSo1xqr
JiWSvT8kDwZaMiVjOmb2tF9dzKmYIsr17I/g9pBHpto0pfiIpNVpCl8XJ0ZyAyMpT2pq9
O7xZ1MSNc3gDdGKvW+7UDpsa/EJ9nUS8VT9yrSYqNZTbrkyJz2VN54tukQehm+gUlgw==
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=NKKCrJA9;
arc=none smtp.remote-ip=209.85.221.173
X-Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173])
(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 EFBC1606A320
for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 17:17:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EFBC1606A320
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-f173.google.com with SMTP id 71dfb90a1353d-5ec6f271883so1384980e0c.3
for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 09:17:21 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794331041; x=1794935841; 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=anu/2F6mroicCWt3l+8C2jxZSamPe+b0q+OPEpgFtcQ=;
b=NKKCrJA9g8WcA1Ou1yzg2Qhs61lb8dcLj5MZUxusyhRetSjLQ36Zg04UidHm6J9a2J
ZVt6Sgq+0eCGLFC3Y7PwAt2B+DLaYU3sLlrlveXZp8FtmrHS6UUmfRgujvJ6b8Ch6QDr
85GUlFDvlsOibkvJsJvKQF4d5qTHlVT3s14fPoFbRd/CdmjDO7i7xGUD7JcMpZeGMGea
QPyWeoKJXsSlgySEFMDNjA3xLGFRuLjZa2I+f3uwbTasnpqZjxiN/ErJxiXE7hhUR/vs
mNpMtW3q2HCePxE8ZMaRIddfrjsD4mR+rip5SVcDsSJ9Yybgu7C/pFbER85AWofvgUdZ
XcRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794331041; x=1794935841;
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=anu/2F6mroicCWt3l+8C2jxZSamPe+b0q+OPEpgFtcQ=;
b=aHlfaWx6bL/aptZvPRFpYDScYNpTKDgBvKlshJ/MQybLDg5K2Cu11D6EAXgS9e3O9e
ZDT1Bc2I37mddJJ7RsoNi/oxYdlVYBD7Npno88tW3e3xLsYwVMC+lYTlT7tDRviAFL3O
H/T8MiVrjaTtApAp06YakmrrCntfbm7EZZ73NVfIFXokRTBgwoH4itr9X4apKOZSo2kD
AQuafD5XX7WaOfq2zNs5Nq+8RjLKn7NpjyHGDETnle/D3kxGjcA+7AvrsroonlqXgZmy
0ymJfDreGhHa+LyVyt2RtgZibcwP3SjF21XMQUWJGxHMe5hUMkmj4Ed5BpWRa0cG+dV/
0ONQ==
X-Forwarded-Encrypted: i=1; AL+hErFt/KCXfNlsOBoZ/RWcA5yImHuoLTZSYVp7dxpqDGeBvgt0p/3VEY+nvwcUJItPnkus9YCoMRw=@vger.kernel.org
X-Gm-Message-State: APuU4Z98UbuUMpqo6LRVVUHzh/WZAqtqmIC4A8N+sco3uMgD4EZZw8QP
SNq4b3/t8GewOV1eMN+cxZC1alN/k+397tJVlnYulq0iSXkAuTMSgz6u9eSE2w==
X-Gm-Gg: AYBFou2mKeX9h4WilJMPWEkK8C6gD+12o8jXfWe8zp0Q+sVz9Naoj5ZQAiOJcLiuyTl
OKlobOxjo0YiJTehGnpP9dN3COa83ZG/BDolElZb1/4Yz0wS0dlZ2x5oooZuJxafMcw/ifbisG4
8uw++oH54BqsDHZDyci7nvMM4JmvjXlqIxkVDPiCVhPVpJUCVGpbazGc4hjLazjE/dnFclZeQno
KyX6skJ25bud1FwkuBT4oCxeMC4q9hPlWqjVdCXOVZufld0SXVmeAuL6A3vq0d4NQ+//WCXbm+S
jNg9KPvWHB8nKYVEYLdRg6xsQ06hXGLkNiRFtiUpUOi5N/whOfmOtagw6gEQ2irbNc4WuWKpy3Z
Npm9Xaef9Unv7DkPJLqCVi0EME+xKmUFkc7rnOS7WcXSzYcdNUJ/9pW/cHKU2TZ9QqEWJEn5H+2
O24bWM5EbguC8ghEVaDwoNipY/B2ZJduu4M5+ZnjNcpinrE8mBIaNKEzNr1+GkxFEQvQ1tIps0F
GZz9Od0QMKMeb37auiKzL0Pxv2NjXWgkSqEZcyklJgBgdBfyQFGgpL88gW4TO07p7bJCICZPUJ5
9qv0Po60S3YP2hu3Ni8uwuFR1a7i3G9pzQQbqj/I0j6QhBtuYy5/sMThlCYKlRIypgMt21uBvjZ
VysCA87Qxo+lIox30h8IDwpza2Pg0Sv0qoES0qX3nahqc2fa7WY0wZX46R4+Y3Rk1dvFt9oM=
X-Received: by 2002:a05:6122:210a:b0:5ea:c722:b3a with SMTP id 71dfb90a1353d-5ee0d0d51d8mr1334938e0c.7.1794331040981;
Tue, 10 Nov 2026 09:17:20 -0800 (PST)
X-Received: from gmail.com (223.230.150.34.bc.googleusercontent.com. [34.150.230.223])
by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ee0c5dace7sm2095563e0c.12.2026.11.10.09.17.20
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 10 Nov 2026 09:17:20 -0800 (PST)
X-Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
韩少阳 <shaoyanghan@deeproute.ai>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
John Ogness <john.ogness@linutronix.de>,
linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
X-In-Reply-To: <20261110072221.24701-1-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