Re: [PATCH net-next] netpoll: Optimize skb refilling on critical path
From: Simon Horman
Date: Thu Mar 06 2025 - 06:48:47 EST
On Tue, Mar 04, 2025 at 07:50:41AM -0800, Breno Leitao wrote:
> netpoll tries to refill the skb queue on every packet send, independently
> if packets are being consumed from the pool or not. This was
> particularly problematic while being called from printk(), where the
> operation would be done while holding the console lock.
>
> Introduce a more intelligent approach to skb queue management. Instead
> of constantly attempting to refill the queue, the system now defers
> refilling to a work queue and only triggers the workqueue when a buffer
> is actually dequeued. This change significantly reduces operations with
> the lock held.
>
> Add a work_struct to the netpoll structure for asynchronous refilling,
> updating find_skb() to schedule refill work only when necessary (skb is
> dequeued).
>
> These changes have demonstrated a 15% reduction in time spent during
> netpoll_send_msg operations, especially when no SKBs are not consumed
> from consumed from pool.
>
> When SKBs are being dequeued, the improvement is even better, around
> 70%, mainly because refilling the SKB pool is now happening outside of
> the critical patch (with console_owner lock held).
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
> The above results were obtained using the `function_graph` ftrace
> tracer, with filtering enabled for the netpoll_send_udp() function. The
> test was executed by running the netcons_basic.sh selftest hundreds of
> times.
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>