[PATCH net 7/9] rxrpc: Fix I/O thread stop

Hillf Danton hdanton at sina.com
Sun Dec 18 04:09:51 PST 2022


On 16 Dec 2022 06:46:01 +0000 David Howells <dhowells at redhat.com>
> There is a window here:
> 
>   		if (!skb_queue_empty(&local->rx_queue) ...)
> 			continue;
> 	--->
> 		if (kthread_should_stop())
>  			break;
> 
> in which an event can happen that should be attended to.  For instance the
> AF_RXRPC socket being closed, aborting all its calls and stopping the kthread
> by doing the final unuse on its rxrpc_local struct - in that order.  The
> window can be expanded by an interrupt or softirq handler running.
> 
> So once we've observed that we've been asked to stop, we need to check if
> there's more work to be done and, if so, do that work first.

In line with

	if (condition)
		return;
	add to wait queue
	if (!condition)
		schedule();

this change should look like

   		if (!skb_queue_empty(&local->rx_queue) ...)
 			continue;

 		if (kthread_should_stop())
   			if (!skb_queue_empty(&local->rx_queue) ...)
 				continue;
			else
  				break;

as checking condition once barely makes sense.



More information about the linux-afs mailing list