summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorSimon Schippers <simon.schippers@tu-dortmund.de>2026-05-10 17:15:26 +0200
committerJakub Kicinski <kuba@kernel.org>2026-05-13 17:52:55 -0700
commitd4c22d70d7253dd727c71484c58d504f6c630343 (patch)
tree8013ba6d03eb2c9f1536d90ba881d77f01d1ec9f /include/linux
parent8ebd24a7822cbae25beeafba49b2159d6a68a5f2 (diff)
tun/tap: add ptr_ring consume helper with netdev queue wakeup
Introduce tun_ring_consume() that wraps ptr_ring_consume() and calls __tun_wake_queue(). The latter wakes the stopped netdev subqueue once half of the ring capacity has been consumed, tracked via the new cons_cnt field in tun_file. As a safety net, the queue is also woken on the last consumed entry if it leaves the ring empty. The point is to allow the queue to be stopped when it gets full, which is required for traffic shaping - implemented by the following "avoid ptr_ring tail-drop when a qdisc is present". Some implementation details: - tun_ring_recv() replaces ptr_ring_consume() with tun_ring_consume() to properly wake the queue. - __tun_detach() locks the tx_ring.consumer_lock to avoid races with the consumer on the queue_index. - The ptr_ring_consume() call in tun_queue_purge() is not replaced with tun_ring_consume(). Instead, within the same tx_ring.consumer_lock in __tun_detach(), the netdev queue is woken for the ntfile taking it over, to avoid a possible stall. This does not matter for tun_detach_all(), as it is called during device teardown and no tfile takes over any queue. - Reset cons_cnt in tun_attach() so the half-ring wake threshold is valid for the new ring size after ptr_ring_resize(). - tun_queue_resize() wakes all queues after resizing with the proper tx_ring.consumer_lock and resets the cons_cnt to avoid a possible stale queue. - The aforementioned upcoming patch explains the pairing of the smp_mb() of __tun_wake_queue(). Without the corresponding queue stopping, this patch alone causes no regression for a tap setup sending to a qemu VM: 1.132 Mpps to 1.134 Mpps. Details: AMD Ryzen 5 5600X at 4.3 GHz, 3200 MHz RAM, isolated QEMU threads, pktgen sender; Avg over 50 runs @ 100,000,000 packets; SRSO and spectre v2 mitigations disabled. Co-developed-by: Tim Gebauer <tim.gebauer@tu-dortmund.de> Signed-off-by: Tim Gebauer <tim.gebauer@tu-dortmund.de> Signed-off-by: Simon Schippers <simon.schippers@tu-dortmund.de> Acked-by: Michael S. Tsirkin <mst@redhat.com> Link: https://patch.msgid.link/20260510151529.43895-2-simon.schippers@tu-dortmund.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions