Subject: Re: [PATCH net-next 1/2] xsk: avoid using heavy lock when the pool is not shared

From: Jakub Kicinski <[email-masked]>
Date: Tue, 28 Oct 2025 17:29:03 -0700

On Sat, 25 Oct 2025 14:53:09 +0800 Jason Xing wrote:
>  static int xsk_cq_reserve_locked(struct xsk_buff_pool *pool)
>  {
> +	bool lock = !list_is_singular(&pool->xsk_tx_list);
>  	unsigned long flags;
>  	int ret;
>  
> -	spin_lock_irqsave(&pool->cq_lock, flags);
> +	if (lock)
> +		spin_lock_irqsave(&pool->cq_lock, flags);
>  	ret = xskq_prod_reserve(pool->cq);
> -	spin_unlock_irqrestore(&pool->cq_lock, flags);
> +	if (lock)
> +		spin_unlock_irqrestore(&pool->cq_lock, flags);

Please explain in the commit message what guarantees that the list will
remain singular until the function exits.
-- 
pw-bot: cr