Re: [PATCH v2] datagram: return from __skb_recv_datagram() as soon as possible
From: David Miller
Date: Wed Jul 18 2018 - 01:16:05 EST
From: Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx>
Date: Mon, 16 Jul 2018 15:17:54 -0700
> If the above occurs, that implies that the queue is not empty so the
> next iteration of the loop in __skb_recv_datagram should return
> the oldest packet on the queue.
Isn't it possible, with two threads pulling from the socket in
parallel, for one of them to be constantly unable to pass that
test:
if (sk->sk_receive_queue.prev != skb)
goto out;
because the other one empties the queue too quickly every time?
We sample 'last' with the queue lock held, but the above test is done
without that lock.