Re: [PATCH net 2/2] netpoll: avoid blocking on the transmit lock in queue_process

From: sashiko-bot

Date: Tue Sep 29 2026 - 02:46:24 EST


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: severe latency in netpoll queue_process on lock contention
--

commit eadeea48c72992b0b24239d8a823d8f836b84527
Author: Karl Mehltretter <kmehltretter@xxxxxxxxx>

netpoll: avoid blocking on the transmit lock in queue_process

This commit replaces HARD_TX_LOCK() with HARD_TX_TRYLOCK() in queue_process()
to fix a sleeping-in-atomic bug on PREEMPT_RT. If the lock is held, it requeues
the skb and schedules a delayed work retry after HZ / 10.

> diff --git a/net/core/netpoll.c b/net/core/netpoll.c
> index e0cfcb05468e2..a3c94f0b3f764 100644
> --- a/net/core/netpoll.c
> +++ b/net/core/netpoll.c
> @@ -166,7 +166,13 @@ static void queue_process(struct work_struct *work)
> skb_set_queue_mapping(skb, q_index);
> }
> txq = netdev_get_tx_queue(dev, q_index);
> - HARD_TX_LOCK(dev, txq, smp_processor_id());
> + if (!HARD_TX_TRYLOCK(dev, txq)) {
> + netpoll_txq_queue_head(npinfo, skb);
> + local_irq_restore(flags);
> +
> + schedule_delayed_work(&npinfo->tx_work, HZ / 10);
> + return;

[Severity: High]
Does this schedule an excessively long delay when encountering a transient
spinlock contention?

When queue_process() attempts to transmit a deferred skb, it uses
HARD_TX_TRYLOCK(). If another CPU is actively transmitting on the same queue,
the TX lock is transiently held and the trylock fails.

The TX spinlock is typically held for just a few microseconds during normal
network operations, but this introduces a 100ms (HZ / 10) delay upon lock
contention. Will this cause netpoll to stall for 100ms every time it
encounters a busy TX lock, dropping throughput drastically (e.g., to ~10
pkts/sec) and likely causing the deferred queue to overflow resulting in
lost kernel logs?

> + }
> if (netif_xmit_frozen_or_stopped(txq) ||
> !dev_xmit_complete(netpoll_start_xmit(skb, dev, txq))) {
> netpoll_txq_queue_head(npinfo, skb);

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928064239.32456-1-kmehltretter@xxxxxxxxx?part=2