🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23619

[PATCH net] pppox: only wait for a grace period for lockless receive paths

#23619
From: Nicolas Dichtel
Date: Fri, 27 Nov 2026 15:28
101 lines
14318 bytes
Commit 92c1bf630abf ("pppox: drain queued packets on channel handoff")
added a synchronize_net() call to PPPIOCGCHAN, so that the receive paths
that observed the old state finish queueing their packets before the queue
is drained.

PPPIOCGCHAN is issued once per session by PPP daemons, so each session
setup now waits for a full RCU grace period. With accel-ppp, the PPPoE
session setup rate drops from ~1100 to ~250 sessions per second, and the
latency of pppox_ioctl() goes from a few microseconds to 4-8 ms.

The regression was triggered in CI testing by a PPPoE performance test
(accel-ppp server in a VM using ConnectX-6 VFs, bngblaster client) on an
unmodified kernel. It was validated by reverting 92c1bf630abf, which
restores the v7.2 setup rate, and by measuring the latency of pppox_ioctl()
while PPPoE sessions are being set up:

  bpftrace -e 'kprobe:pppox_ioctl { @s[tid] = nsecs }
    kretprobe:pppox_ioctl /@s[tid]/ {
      @us = hist((nsecs - @s[tid]) / 1000); delete(@s[tid]); }'

Only L2TP needs this grace period:

- PPPoE receives packets through __sk_receive_skb(), which takes the socket
  spinlock and moves the skb to the backlog when the socket is owned by the
  user. As pppox_ioctl() holds lock_sock(), pppoe_rcv_core() either
  completes before the PPPOX_BOUND transition, or runs from release_sock()
  and sees the new state.

- PPTP never queues packets to sk_receive_queue: pptp_rcv_core() always
  hands them to ppp_input(). Moreover, PPPOX_BOUND is set as early as
  pptp_bind().

- pppol2tp_recv() tests PPPOX_BOUND and queues packets under
  rcu_read_lock() only, without taking the socket lock, so it can race with
  the transition. Waiting for a grace period is required there.

Add a lockless_rcv flag to struct pppox_proto, set it for L2TP only, and
wait for a grace period only when it is set.

This fix was tested against the reproducer: the setup rate is back to ~1100
sessions per second, the same level as with the faulty commit reverted. The
pppoe.sh and pppol2tp.sh selftests also pass.

Fixes: 92c1bf630abf ("pppox: drain queued packets on channel handoff")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/ppp/pppox.c  | 7 +++++--
 include/linux/if_pppox.h | 4 ++++
 net/l2tp/l2tp_ppp.c      | 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ppp/pppox.c b/drivers/net/ppp/pppox.c
index a6f72c813bef..8d73951b8013 100644
--- a/drivers/net/ppp/pppox.c
+++ b/drivers/net/ppp/pppox.c
@@ -93,9 +93,12 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 		 */
 		sk->sk_state |= PPPOX_BOUND;
 		/* Let lockless receive paths finish queueing against the old
-		 * state.
+		 * state. The other receive paths take the socket lock, which
+		 * is held here, so they are already serialized with this
+		 * transition.
 		 */
-		synchronize_net();
+		if (pppox_protos[sk->sk_protocol]->lockless_rcv)
+			synchronize_net();
 		/* Drain packets queued before the handoff because a bound
 		 * socket is no longer readable.
 		 */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index 594d6dc3f4c9..29447a0666a8 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -64,6 +64,10 @@ struct pppox_proto {
 	int		(*ioctl)(struct socket *sock, unsigned int cmd,
 				 unsigned long arg);
 	struct module	*owner;
+	/* The receive path may queue packets to sk_receive_queue without
+	 * holding the socket lock.
+	 */
+	bool		lockless_rcv;
 };
 
 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 4f311d473a64..9109c7c156a5 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1708,6 +1708,7 @@ static const struct pppox_proto pppol2tp_proto = {
 	.create		= pppol2tp_create,
 	.ioctl		= pppol2tp_ioctl,
 	.owner		= THIS_MODULE,
+	.lockless_rcv	= true,
 };
 
 #ifdef CONFIG_L2TP_V3
-- 
2.47.3
Technical Details
Message-ID: <20261127152822.2098330-1-nicolas.dichtel@6wind.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372820-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372820-linux-kernel-netdev=dewy.ru
From: nicolas.dichtel@6wind.com (Nicolas Dichtel)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] pppox: only wait for a grace period for lockless receive paths
Date: Fri, 27 Nov 2026 16:28:22 +0100
Organization: Usenet Network
Message-ID: <20261127152822.2098330-1-nicolas.dichtel@6wind.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="761591"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ultmTIREGvbTrO3WLPMnPiTM4W8= sha256:wN8XIf+QG5ZMwkYnndyttZICi+X0+VTgkEZdYsSFOuU=
	sha1:aEMNy4RMC5iV0aR9d+CcBm0bkhQ= sha256:PS56dzYvXpqPbncfmy5cOH0xOpXric0LMTeQPcsvusU=
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 6AA27125F61; Fri, 27 Nov 2026 18:30:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=6wind.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 vVP0R9-ZACVU;
	Fri, 27 Nov 2026 18:30:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372820-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=6wind.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 5A590125F5E; Fri, 27 Nov 2026 18:30:13 +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 90A6E3B210; Fri, 27 Nov 2026 15:29:14 +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=1795793327;
	b=E5Y4wb/7XXwyHJLXfPAzsmtzEf94ay5N+Vjan8OKY8XU3maoCGnde2NmAZ2OCMVOY+SK
	 fK/y1AcqLI+ZpK5F10g2KB+fd5TTxSgdMurjLJgON5plOKggY8FJrjws5K351b7qe6cCB
	 0cD/qS2R3u3YdpT/P1jrMCk2PXTpLOCcF6zekUfV9U7knuFJEI2NWlPlub97U3F+vwiP0
	 Ooa3x4XxlOrlb+nNjaxrLfRLOyfwgJTYnkPj8wiMI6G29MB7i7dCsbGEW2D0g6W3Qe+Ws
	 NEuvTg5ru/Kwvq5i4LI3A/HD3NWTNBNJSjdOCqJn+h+IV/ZxbwVSpxlLRAcX7kLfHxg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795793327;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:X-Relaying-Domain:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=y9Cy6S/dJOP0Wkat096mayPMPffl30NQd/fiIAUB+XI=;
	b=lJrEVOTrjIDrJduEZggSQI2gb8Us8hs4DPaGrOWK5N3ilzXz8ms7rg+df+ZjJAFmLqyc
	 17stRaGLbTzfBjjWMp8x+aoPCL7UqAA2Zer8Pr3yHJWvdNh2++Usl1QBdm49aUSpm4Bfp
	 gnrfv+A5DJW6/5RJOagMprdKmgbKgu4z3cgeem+5oxsLpJz+Gvsf4e4V2xk+yg6rMLaQJ
	 7EK/gpuCErcRLzM75Ipjk9YNOGlrYDe6wxkgGOBi7Hh4vIqhv3lJ2ke1R+faUFfALbgT+
	 unXFRw2ywbjAn6jNXhTJxauj41bs/XRU1sMXTajF8VtqWtv2RK5xvyAx+78LTHiVkZA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=gM52dHey;
	dmarc=pass header.from=6wind.com;
	spf=pass smtp.mailfrom=6wind.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 85A4B606B772;
	Fri, 27 Nov 2026 15:28:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=gM52dHey
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.97
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795793326;
	b=MG8YcEBbtJ7n3p9XRz2CAoEkGiUXsO6r4w3S9m/2WH6clZRQiI44PYOWHw3+v7eFwDib
	 hUuyjUT78Y3BF0NpHitJ2QIT7r/3iTZ9Yej2DcwLp+t3UJ4bZUsWRCB+gw6+91odmFxFc
	 i6JJ64Udj9PhIE7vT8xbtwuIAiqsxV3z1IyoCzY/Mk+AyL9+bBlT8OgGzZYq8+n3cV8+/
	 yKRPET12vHCYN59V0EfYO9DncjAyCnlI4Q7WLnsrGoNKRAvxf1X0sjxVXbp9YXj1xkqDZ
	 OqnftQrgGMoBozGB5eLteDp8lmPzSH/b5FIFXUr8ngiPgMU3QlNKIVaxwbcNDJTQKpQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795793326;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:X-Relaying-Domain:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=y9Cy6S/dJOP0Wkat096mayPMPffl30NQd/fiIAUB+XI=;
	b=ylGEZluHGs/JkTQ9SGaNTGv/NpO5XRyCmfbYmkcYx/tr6QencQ1UKemtTvQhSFB0AxiQ
	 YTCLne4TRlsUhmevEIgqJQUdTIcgeORHvlFTmZc21hab0TDT+KJ6aWbPEEqWUr9m7Y0KS
	 mgTFGFozVljgmIQt6qWF5A99uw3oLFQ/ZyIPb/qtvgo+I/9/SJe/rpWKw0I2vVlTXGluL
	 +T6vzsKb8pT0veaLYK9DmKTrbvqjHKgXoPXRkDFo8B5SUCaSzp+h68Es6+WR3K6ZJ17Ij
	 9J7yKfGkPhYtmh6y+R8sQlfVrtxZnFjQm3gxER7nRBfihMJMYsP2d/1bN/o2TPrza4Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=6wind.com;
	spf=pass smtp.mailfrom=6wind.com;
	dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=gM52dHey;
	arc=none smtp.remote-ip=209.85.128.97
X-Received: from mail-wm1-f97.google.com (mail-wm1-f97.google.com [209.85.128.97])
	(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 423A7606A681
	for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 15:28:46 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 423A7606A681
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com
X-Received: by mail-wm1-f97.google.com with SMTP id 5b1f17b1804b1-4bbb0db845aso917115e9.1
        for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 07:28:46 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=6wind.com; s=google; t=1795793324; x=1796398124; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=y9Cy6S/dJOP0Wkat096mayPMPffl30NQd/fiIAUB+XI=;
        b=gM52dHeyaSiVd0xSq5PJisvfLe1WAPMBqAyJCMY26cu5aLTTm3EXgCfm8zRYYNe49p
         R1fHun/+HwpRZIVQS8hOVTOCwTXZF0DnXb/01Z0YWHSSZOW/j9n3W4TT4aBkMF1zlIQE
         VJDklzShYFc/cXUI/jcULu7NA9/TcIxd2rCotGnpp+3p1SMPUtxn5VWYQ2HgHfImijD7
         gahFIQFs72cgzh967NAgN7dHWBvkUSuQdOCW2B1mvEamloZDugBftVFIK0rihHVVRG5Y
         J4ea+RFfWtzHWrp7pFtdAntX27kjpS8W2oIK2UkJcSp8GSjSPHvOwgCYyylHMBb01HMM
         g/nA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795793324; x=1796398124;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=y9Cy6S/dJOP0Wkat096mayPMPffl30NQd/fiIAUB+XI=;
        b=CwC8lozgzj+H3fIT1i6mZIVHIlfp+XdAC7yCOH9Tc5Jf20fqo52HXsJ7xHDwnUY6Ro
         +y/aiQ8zTvvBZHqqipI4MGBSqxUvlPjN6jRFWZ3awQjwQFzxn2/R49rWNaSCyDgmCQ26
         yx5fMAm2DvM0WzvdxuVp7Oxmy12Xc7szcMDc+Zn/lGjXiuIowqT7FrCdbcz2uiCdV/nP
         KzZHYKou6pfqaMlN+ItkUCMpFQ6uDoV4XDftmVehMfxuHK/j23bau8CAGgJKrtC1gYkC
         xxtka9JpSi4r8DYHzXLc7wmp/0jskDBsk71u4YH87MBqTS7mKaqPK6KaurbjAktFT82h
         ghjQ==
X-Gm-Message-State: APuU4Z/2qV+Zx85R72D4+yoonEdSjZnlx68Hyz/ARhNFJprGLjgL1O2o
	Mwhy/fSKzDU+uKSWz5EUDkpr+PgH6xb4HCgApaMBDgiXhuzK91k6Yw9SY3OmoVHUgDQjX1Lco5l
	puX1KRhEsSaytNPIx8+hXvtAtbVuYixA7RiQx
X-Gm-Gg: AZFdTZcRUDUqMTFraiqArIvAp4YXEyVnjmCo76R7eB9eaqHIcnFjdJ4AM9G1X2fGB2Y
	IKp+hYy/9rLV2D/6/DdBXg7xH6QFI0SE19Sm6XdpgJEfXThmg4RfyUb9GCfF5g6cwET4Lr//B2i
	nni9kyWXuFX/0sdDsmtvYBM9FO/XG9zaNbmiSC4d3+tWJP5sg5eOPCs1jZvGsUsHVv+amWrUDDw
	AQNe1E+H6MmN5TjnNlIucC3HRvjOTd4Yk79aj3dgBdZoL270lwnNMmINMGktHuLVTiSdgmgPgzn
	Q3KCvG1mbBta3hNxr3ssBnRcQz3KeYfzwzw9LlMfnpJ1LAAdDCfWoQN7xu61iAelQhTgotAWkU+
	NLxa65zd6axeoQW5BaHkPOGf0dA==
X-Received: by 2002:a05:600c:8284:b0:4bb:6c01:de9c with SMTP id 5b1f17b1804b1-4bb887f55c1mr451870655e9.2.1795793324518;
        Fri, 27 Nov 2026 07:28:44 -0800 (PST)
X-Received: from smtpservice.6wind.com ([185.13.181.2])
        by smtp-relay.gmail.com with UTF8SMTP id 5b1f17b1804b1-4bb853aa2a2sm91105585e9.10.2026.11.27.07.28.43;
        Fri, 27 Nov 2026 07:28:44 -0800 (PST)
X-Relaying-Domain: 6wind.com
X-Received: from localhost (bretzel.dev.6wind.com [10.17.1.57])
	by smtpservice.6wind.com (Postfix) with UTF8SMTP id D030A13D8D;
	Fri, 27 Nov 2026 16:28:43 +0100 (CET)
X-Cc: netdev@vger.kernel.org,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.47.3
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