Article View: linux.kernel.netdev
Article #22622[PATCH net-next 1/3] ptr_ring: add PTR_RING_BATCH
From: Simon Schippers
Date: Wed, 25 Nov 2026 15:23
Date: Wed, 25 Nov 2026 15:23
38 lines
10027 bytes
10027 bytes
Name the batch size in which the consumer frees entries, so that users
of a ring can size their own work to it. The next patch uses it in veth.
No functional change.
Signed-off-by: Simon Schippers <simon.schippers@tu-dortmund.de>
---
include/linux/ptr_ring.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 631c43fde4407..b851a9c170bf6 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -27,6 +27,11 @@
#include <asm/errno.h>
#endif
+/* Consumed entries are freed in batches of this size, unless the ring is
+ * smaller than two batches
+ */
+#define PTR_RING_BATCH (SMP_CACHE_BYTES * 2 / (int)sizeof(void *))
+
struct ptr_ring {
int producer ____cacheline_aligned_in_smp;
spinlock_t producer_lock;
@@ -506,7 +511,7 @@ static inline void **__ptr_ring_init_queue_alloc_noprof(unsigned int size, gfp_t
static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
{
r->size = size;
- r->batch = SMP_CACHE_BYTES * 2 / sizeof(*(r->queue));
+ r->batch = PTR_RING_BATCH;
/* We need to set batch at least to 1 to make logic
* in __ptr_ring_discard_one work correctly.
* Batching too much (because ring is small) would cause a lot of
--
2.43.0
Technical Details
Message-ID:
<20261125152311.805325-2-simon.schippers@tu-dortmund.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371476-linux-kernel-netdev=dewy.ruReferences:
<20261125152311.805325-1-simon.schippers@tu-dortmund.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371476-linux-kernel-netdev=dewy.ru
From: simon.schippers@tu-dortmund.de (Simon Schippers)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 1/3] ptr_ring: add PTR_RING_BATCH
Date: Wed, 25 Nov 2026 16:23:09 +0100
Organization: Usenet Network
Message-ID: <20261125152311.805325-2-simon.schippers@tu-dortmund.de>
References: <20261125152311.805325-1-simon.schippers@tu-dortmund.de>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="241267"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7ihfF6tyOPaI0RW5xSqJ9q9zNuI= sha256:WUIY7PRwXFjUAO5oTkEAb91U/pbvrP6n3gWbuJC5Jkw=
sha1:4t46VDu+3RFbhH64s729GYCVdHs= sha256:fi6TjUKSzlrFP6mfZUKJLsMOwU4W72SfzKrsmS54+aU=
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 3FFDE125E7C; Wed, 25 Nov 2026 18:24:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=tu-dortmund.de
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 z4X0il08SgwH;
Wed, 25 Nov 2026 18:24:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371476-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=tu-dortmund.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 5321E125E79; Wed, 25 Nov 2026 18:24:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 5F61A60F90; Wed, 25 Nov 2026 15:23:52 +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=1795620228;
b=0XNUk9QIpWun2QWMVqoS4bpu49iAFzM8Pf87gP/iyzTIxDDUQvi14Q+qFvjzMjMAkSsn
UqhiRk1nFOTcUMCkvLuSh16FhFkz5bR/CpDEsmuJVToRrvRafkFz4XeQY9oKi8eBXAPqo
27WMJ7ULs1OQPZ+t/4XTGH+5lafTBba/lko8GA+Nq0ijhit+kxMxSqp8gMSOj+GzHy054
cZhXipJV1crSZPYUZ3WtdXCM2+sQ3luGdiBCJD81xprxktI291cywdegSlxvwLz5bhuIe
d8c35d5VRJMTSjuaS6Bglr7i18P4uR3GJ5gFsA+GKzW7WgK9nxB731FMjfN/VFDPZOg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795620228;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=SC6SmwcOlRX4TMShN4/z5oFu7ovHE/zxGHPprunnak4=;
b=rftHN5tJyH51cdy++pTAmq8rtHDAbZKF9TYoE+wIs3FFT+FOmKmHle7VnuuJDo0O1vXE
mIJCj2W0ZIJVqUe68PeskYz2Y31WA+DFidL+BDHrgKz+GsnBGszRj7aZ7wLoCCsSQIDvx
TMcr1tJ0kIsiNPIB/PywbzXitKMazqtd3UGqt46tSSwiahQiA5eGNdlQtNDC7JoG2GZiX
TQlpfzSxXofbfT3FVvgfInlfUZFY9UmP95iaIzSXFSBMz/0moJuhdvefnFFcTWuoqMaKQ
IMpAfLORqGh7RHz4N8xkXtjuXqT+pVm+kuyiYakDK3ANm1mle9N4rnapOdT8V/u+hag==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=V+LxSgX+;
dmarc=pass header.from=tu-dortmund.de;
spf=pass smtp.mailfrom=tu-dortmund.de;
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 D7D89606A336;
Wed, 25 Nov 2026 15:23:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=V+LxSgX+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=129.217.128.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795620228;
b=ljEQKhdi14c/xsWSPoUZq43qiDZduTP7OPUig3YpgipUSJx6mTuZlsG64VHpl2K5Kka1
NmvagpiDNGoS+X58X/91XPfCRpxyvTuBrAhvng4hdxKQgVb5KyCvRiUVNIvtgxTLnm/Kr
g2xzbFSaSgiQhVicS6wXCKVor0hH6YVKEd/0Km3NI1gD/AjF1x1c+PqtOQXwAtrevP2YB
sNEauj6/k/ZGuy/DFmzVFI38LEcAyvxhlXVXlvZnrX5Th1tle4tCiw98EwT4frHph+qWK
aW/zEsrFfFK7yI5rFquBsFANopna4YxOXzGBXkc6VB+DjixhUmHAHjjf/8ZWKm1jTqQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795620228;
h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=SC6SmwcOlRX4TMShN4/z5oFu7ovHE/zxGHPprunnak4=;
b=b07eff3y7sgKZ1HeqhacBMzcPvIZV/ex6V5na9VcIFX06BoJyg3z0bDFqlyPF/FdwMjv
SOotbwBbhREzN2Lx/10CaguZ2DVe+tRlbD2bQ/TWsnK0/mqAOvG2JB0cTZi49H5jvh0hb
utAXqxfkCc03M2AQk7+30wmvEka50b4DojrmkPL0CVLsti/HoMxE1j6+wojqbi8PEJsLV
AdaAZ3uhRq+9XYr/s1USC4jasog0m+vBdWUQ0DVvd6ZVdp3m9gSC/hpw3SVjhlLFZu6EU
IrG1lsBvZSCbVLrlquZ/JYbfmB6F0cJk2fqwyBYUw5syMqWklFLqSr16kPlGufbhtuw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=tu-dortmund.de;
spf=pass smtp.mailfrom=tu-dortmund.de;
dkim=pass header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=V+LxSgX+;
arc=none smtp.remote-ip=129.217.128.51
X-Received: from unimail.uni-dortmund.de (mx1.hrz.uni-dortmund.de [129.217.128.51])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AA28606A323;
Wed, 25 Nov 2026 15:23:45 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8AA28606A323
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tu-dortmund.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tu-dortmund.de
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tu-dortmund.de;
s=unimail; t=1795620198;
bh=SC6SmwcOlRX4TMShN4/z5oFu7ovHE/zxGHPprunnak4=;
h=From:To:Cc:Subject:Date:In-Reply-To:References;
b=V+LxSgX+xOIGZKNib5pjO6K9VDNuowVOl3A9tvaUAg8D4bIdEXr4w9BVkbNfpKzK+
e9D8yq/Sx9zz8wwRgyZtt8F8WJ+bT6MpXvptSn1HIYJCBMbp/koMDX2bg8NQaUaEHb
PQv1QiViB8LXTIvM0WkHfWq+4KVqoPUSFtG9aGbc=
X-Received: from simon-Latitude-5450.cni.e-technik.tu-dortmund.de ([129.217.186.207])
(authenticated bits=0)
by unimail.uni-dortmund.de (8.19.0.2/8.19.0.2) with ESMTPSA id 6APFNERM004665
(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);
Wed, 25 Nov 2026 16:23:17 +0100 (CET)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Tim Gebauer <tim.gebauer@tu-dortmund.de>,
Jonas Köppeler <j.koeppeler@tu-berlin.de>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowangio@gmail.com>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
Simon Schippers <simon.schippers@tu-dortmund.de>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261125152311.805325-1-simon.schippers@tu-dortmund.de>
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