[PATCH net-next 2/3] pppoe: transmit without the PPP channel lock

From: Julius Bairaktaris

Date: Sun Nov 29 2026 - 09:43:32 EST


pppoe_xmit() reads the session's device, session ID and peer address,
which are set before the channel is registered and stay valid until
pppox_unbind_sock() has unregistered it, and hands the frame to
dev_queue_xmit(). It never refuses a frame. Set lockless_xmit, so that
ppp_generic calls it from several CPUs at once without the channel lock.

pppoe_release() and pppoe_unbind_sock_work() clear pppoe_dev before
they unbind the socket, while frames may still be sent, so annotate
those stores and load the pointer once with READ_ONCE().

With one iperf3 TCP stream per CPU over PPPoE on a veth in a 4-CPU KVM
guest with lock_stat, ppp->wlock was contended in 805475 of 3245131 and
in 530957 of 2517080 acquisitions before this series (two boots, three
10 s runs each). With it, a kprobe on ppp_push() counted no call while
pppoe_xmit() sent 2684816 and 2316508 frames, and lock_stat lists no
acquisition of ppp->wlock or of the channel's downl.

Signed-off-by: Julius Bairaktaris <julius@xxxxxxxxxxxxxx>
---
drivers/net/ppp/pppoe.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index de6edc31790f..f14ed72eb9d5 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -400,7 +400,7 @@ static void pppoe_unbind_sock_work(struct work_struct *work)
lock_sock(sk);
if (po->pppoe_dev) {
dev_put(po->pppoe_dev);
- po->pppoe_dev = NULL;
+ WRITE_ONCE(po->pppoe_dev, NULL);
}
pppox_unbind_sock(sk);
release_sock(sk);
@@ -523,7 +523,7 @@ static int pppoe_release(struct socket *sock)

if (po->pppoe_dev) {
dev_put(po->pppoe_dev);
- po->pppoe_dev = NULL;
+ WRITE_ONCE(po->pppoe_dev, NULL);
}

pppox_unbind_sock(sk);
@@ -639,6 +639,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddr
po->chan.ops = &pppoe_chan_ops;
po->chan.direct_xmit = true;
po->chan.xmit_offload = true;
+ po->chan.lockless_xmit = true;

error = ppp_register_net_channel(dev_net(dev), &po->chan);
if (error) {
@@ -814,7 +815,7 @@ static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb)
{
struct sock *sk = chan->private;
struct pppox_sock *po = pppox_sk(sk);
- struct net_device *dev = po->pppoe_dev;
+ struct net_device *dev = READ_ONCE(po->pppoe_dev);
struct pppoe_hdr *ph;
int data_len = skb->len;

--
2.53.0