Re: [PATCH net-next v14 2/5] tun/tap: add ptr_ring consume helper with netdev queue wakeup
[email protected] Wed, 05 Aug 2026 01:57:35 +0000
| Newsgroups | org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] vhost-net bypasses `tun_ring_consume()`, causing permanent TX queue stalls when `IFF_BACKPRESSURE` is used. -- --- Patch [2]: [PATCH net-next v14 2/5] tun/tap: add ptr_ring consume helper with netdev queue wakeup --- commit 751c5819e676787b1b9d745ec0ad8353ee77415e Author: Simon Schippers <[email protected]> tun/tap: add ptr_ring consume helper with netdev queue wakeup This commit introduces tun_ring_consume() that wraps ptr_ring_consume() and calls __tun_wake_queue(). The queue is woken up when the ring is half empty or entirely empty to support traffic shaping with IFF_BACKPRESSURE. > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 51e80000bd0ed..d49b6bfd104db 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c [ ... ] > @@ -2116,13 +2171,61 @@ static ssize_t tun_put_user(struct tun_struct *tun, [ ... ] > +static void *tun_ring_consume(struct tun_struct *tun, struct tun_file *tfile) > +{ > + void *ptr; > + > + spin_lock(&tfile->tx_ring.consumer_lock); > + ptr = __ptr_ring_consume(&tfile->tx_ring); > + if (ptr) > + __tun_wake_queue(tun, tfile, 1); > + > + spin_unlock(&tfile->tx_ring.consumer_lock); > + return ptr; > +} [Severity: Medium] Will vhost-net bypass this wrapper and cause permanent TX queue stalls when IFF_BACKPRESSURE is enabled? Looking at vhost_net_buf_produce() in drivers/vhost/net.c, vhost-net consumes packets directly from the tun ring: drivers/vhost/net.c:vhost_net_buf_produce() { ... rxq->tail = ptr_ring_consume_batched(nvq->rx_ring, rxq->queue, VHOST_NET_BATCH); ... } Because vhost-net uses ptr_ring_consume_batched() directly, it bypasses tun_ring_consume() and prevents __tun_wake_queue() from being called. This leaves the stopped netdev queue permanently stalled. While IFF_BACKPRESSURE is currently masked out of TUN_FEATURES in this commit (meaning it cannot be triggered by userspace today), this structural flaw in the backpressure design will trigger unconditionally once the feature flag is fully enabled. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2