๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Nicolas Dichtel Fri, 27 Nov 2026 15:28
[PATCH net] pppox: only wait for a grace period for lockless receive paths
#23619
Author: 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
Re: [PATCH net] pppox: only wait for a grace period for lockless receive paths
#23642
Author: Qingfang Deng
Date: Fri, 27 Nov 2026 16:08
51 lines
10709 bytes
Hi,

On 11/27/2026 11:28 PM, Nicolas Dichtel wrote:
> 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.

I'm going to remove the serializing __sk_receive_skb() from PPPoE, then 
this issue will resurface.

Please consider either using the non-blocking call_rcu(), or just 
dropping all the skbs in the receive queue.

Best regards,
Qingfang
Re: [PATCH net] pppox: only wait for a grace period for lockless receive paths
#23646
Author: Nicolas Dichtel
Date: Fri, 27 Nov 2026 16:25
13 lines
11877 bytes
Le 27/11/2026 ร  17:08, Qingfang Deng a รฉcritย :[snip]
> I'm going to remove the serializing __sk_receive_skb() from PPPoE, then this
> issue will resurface.
> 
> Please consider either using the non-blocking call_rcu(), or just dropping all
> the skbs in the receive queue.
Thanks for your quick answer.
If dropping all the skbs in the receive queue is acceptable, I will proceed this
way.

Regards,
Nicolas
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads