🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15802

Re: [PATCH net v5] af_packet: avoid waiting for TPACKET_V3 copies at retirement

#15802
From: Willem de Bruijn
Date: Fri, 13 Nov 2026 15:11
47 lines
13556 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.3a16e755c0d38@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362717-linux-kernel-netdev=dewy.ru
References: <20261113023809.24730-1-jingxuanxie@deeproute.ai>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362717-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5] af_packet: avoid waiting for TPACKET_V3 copies at
 retirement
Date: Fri, 13 Nov 2026 10:11:18 -0500
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.3a16e755c0d38@gmail.com>
References: <20261113023809.24730-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="1373697"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:SUh46WXQTfjQfB/UBwor88PIMM0= sha256:9ML5JN6s5fFe0ToEsJpF4Ytn5hCtO7a7oQzf6C/Gh2U=
	sha1:UWeFr5l9JfG105AkwvgzNV7gURs= sha256:C72mjsbGjsJ7DsCrXpkrXy/aSKLVMGGa/0KuF79OcbY=
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 6E7BD11458D; Fri, 13 Nov 2026 18:36:32 +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 IqvltWNXfGzO;
	Fri, 13 Nov 2026 18:36:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-362717-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 E844911456A; Fri, 13 Nov 2026 18:36:19 +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 1EB19107A66; Fri, 13 Nov 2026 15:11:34 +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=1794582682;
	b=wchAhFuIf9S7GV7HjWuoCdW9uhg2ZJP5lRzQA9/e1EMna5ZvVUbMcXZuZc+J8pdv/LRd
	 3PDBqz+C9sl5HfFSN/nj7aWrqtiMXGr+ZAoeM1d+i8h/nf4iYOodyYaytbdRCQwpZUPV+
	 qJrFxxQ8BYqYzohST/Q74QpVruxcehbxxxyPmRVfA/8Zeklne4eYvJMk4siXzlsL/uIGm
	 aoncrusA7RO3EDjuHpCjsYH65+n5LySzxanI9MoYZ1IwqPTQMzPrdrtn1xmOw4u/Y9c5O
	 KpvaHN10CB/BeN5nbULACDJf7j2GGvJybNOMZxluECF20rYfOIjCOrT+8WK0+2VOU/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794582682;
	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=qFweTpuVGRGrPONnYBJfMEn8hDYFOEo4C6s0Ul3fY9XDnmrEtPDOgiwARJoAQ9Qv3nzN
	 w3OwGkZxl+hhgQmQxtZUuCUxv+TVABNQwx+/lq9eyZ7EHdnZECJj841JhMoihAzRn7KVz
	 RUwQzuFEJ0e8yBlP8V1J7qehUvnHTq9FBVWScE9WzI70GsdLPiOeaOZj0uib+eQmRZW0A
	 KdQ+gGlg9iDpvGVL0dcWHziWlc8VxqVb28s9k4Kg75sqyfA3sdjq9kXhE2RHXSImxn9GA
	 0V0BIPzi6Jv/4ixEgZVWalKs8KpIh3++kM2wiqhHbbVOIFuMqR9isbKirZdODYv/aKQ==
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=u1BE18LQ;
	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 8AFA9606A894;
	Fri, 13 Nov 2026 15:11:22 +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=u1BE18LQ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794582681;
	b=BBOk+VFN6T0sEOhZrvhscDZytDddWLbemltxictxcMaVo0pykWYHvtEx/kCq6a9/swfV
	 EjIotUhz/JRfWbpQzlF2SVOsMh+5N9pz9wa8diG65mQdw7HYBlESfAPouIeeJvcxLNXAk
	 FI+kzTd+f9tpE/Bho6Q/EyWHzFlOkoC5oxWjwDBhatuEysSeHvKHixwMW2GOaQcrLCz8q
	 1nivHvxtUJZmJ81UNpMc4ynOmqnn39STJoUyzaUJ1S3kjhqJVv34OBRqdrsg/39fsui0d
	 oTG4X09PLL+r7t5F9G9+LfouHbNflTAaumNd5LKsUA75AanusPv8e/XcqRNpN9SJrag==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794582681;
	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=xnjy4Z0byhXmnLEr9+wLDOhhzWxq9ZSj2b7HHZSND18YVgAMecNjDe19rGamRyuHQiFQ
	 0rmEygs6+/Du/YO2F8OTei4cisp6Sp9lc945X6mlB3bqS3vRTpTrUZI+pDMENL02+Sd3R
	 I9FRYixlU7thJ043PRY8vGK2FNwqW077HCJdJFFLPx75L/zmnZBrAKem7dABBomfUdEa3
	 v/mvOh9l5o0wP/xUDT4x8pI4JnuDbqw+DGDgCSQ6jro6n8tL+EgRg2wUSoJBqYNLTQ4LR
	 vG4uWQjeqh1LqwCmbGFLbnjStskSYdQHItvVaW5ZdUDqg/3Fz/EqiWM/8zZRF98M39g==
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=u1BE18LQ;
	arc=none smtp.remote-ip=209.85.222.45
X-Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45])
	(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 61102606A334
	for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 15:11:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61102606A334
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-ua1-f45.google.com with SMTP id a1e0cc1a2514c-98c7798ce74so298654241.1
        for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 07:11:21 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794582680; x=1795187480; 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=u1BE18LQ5cUCwlaJfHj8b/uAgIGAk423ZAbmEWwKAu3EGxGmmyFxlc9jRLwzuc/TFe
         bxUCAmF004E0WxA9Yj5yqfdlupxGmr+wsD36wQO+QPoEa/E55jjxGQqpiE9VfqEo6B5T
         d9bzKOO25H4LY7GPIZ0uNRdqFMXUVr04oMfAWizbicvVmWXxRMLLTTgIEjYhceJIJgv6
         SECq82jRNEunGe8utF/T0uCeRmKESmWjuN16PdmF6RjrAQ24wWdz+mguRSHmLxHMOjIo
         z9ULhYDXsz8dASsujCSzK55o06RJ8temYBXI7Bk9s3R3ZNCVJdoKXaDfQx+4SU49O2XP
         yBTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794582680; x=1795187480;
        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=P19xQZ6n9YsAZXxTwsHvZF+x/Mf38pjoCzh8rVdILC38FQdei2o1jxjr8YbNc/GNNm
         qe5oIzdExd7Lrq3wA40Q+Et050XUdvIv7AHRjdry+XWMGx+g4iMAoCahtpUbTONDvmDV
         znbQq/s3VekKidwRMdskzzcazQyYm8jq+ujy4equz/cCo0uwhDI2ByD33+u92moPsIBQ
         GAot8OVqAW4DG8seUZOi2JpnXJqnOxm9blh8F2CNNCrwaFzQBKEn4ixjYQOqjbZ8lt+I
         w044EZ0aG/Y/NmekUoGcb3EusuUMlqdEX+zMFzHBtRXBZKAN/hLj0cgwh5lU3qNY1EKU
         rA3g==
X-Forwarded-Encrypted: i=1; AL+hErGcgeigOdPC8yjq/RQRV5io20X6LYWaEPDVeOFgp0dAyaO9qjo/UWnY2JpLLCU7/pnbTwWpoa4=@vger.kernel.org
X-Gm-Message-State: APuU4Z+buJSP3REoJUVgaztxd7RiTzeU8JSHf7XGp3EWgos3tYjhcRGF
	EtzUbDREThu67+ZfYO0m9tqNKb8K4PrnRbKr6cdGVa4Cn3r8X2/pXSDw
X-Gm-Gg: AYBFou0mvohhAzS6Cw9plA9orChsij1CgDSWGInTCU2lYv+omcLDUScaL5P/6n/lYN+
	Dt2F5HcDTxsrEWsWRuzm7IglQVlcq7DdS41IBNGBsUo2O3ofSDq6LbtSJYJnGDhK8wS5q8blhet
	WKxp0GwcFQoMb16R16y0iSVNXqHmGORdOAIoAnKjhdkWx8r0+QBzsbWEKQ5RfzMXBlkXHJy2JNp
	GfpAYgSPlN/BFOWgf50cJJWhRiXZ28dp8gzUqNsw6UKilK7LcpKXhHljb0ZxVsNk1qhRMJYvSoY
	IU0AfS/1xEElA6vca48qCT3SdwScuBDEroRbyBei0jCBW+j+fOg8qd9OOY2Ox/jJaINo1ibhZcg
	Rd2YbJl6/T/2i6L0+uXYlCVvmaKeE5dJxCrx7qkQp2gJ/BsymPM3LAjmTPxRMhS7B9qrOc1Ia/M
	2+af73eLc9mytkKW3Y+FjZMgFlbw+tCXMLFZpFg1YTIrMF+9l3HaJ4QX24CzLQGFd8m51w06J6G
	FPyWEEARe13Vd/J6c8SPfvmNyoRvpoPKOoN3SCxcBSG+sErrGT8TAAKmgCVibxUKDgLEBpNarJV
	2ajrgDEvPlSF0dirfRzUTTwZcAxCubCWLRRn+qtY/vDdYmBPfHV661GPDuDxu44mbkJQ2EiaX10
	lmUTjc751+O4S5+SarS6Lg09Vp+DmV7iYGx598sA+IuYXIln1w1V0GoQOkljzpJqV8+l7x40mKk
	3ooNenbqag
X-Received: by 2002:a05:6122:1816:b0:5c9:a60b:e5c0 with SMTP id 71dfb90a1353d-5ee34aaf4ffmr865841e0c.16.1794582679986;
        Fri, 13 Nov 2026 07:11:19 -0800 (PST)
X-Received: from gmail.com (15.60.86.34.bc.googleusercontent.com. [34.86.60.15])
        by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ee34e32f83sm1472842e0c.6.2026.11.13.07.11.19
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 13 Nov 2026 07:11:19 -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: <20261113023809.24730-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