From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH v2] datagram: return from __skb_recv_datagram() as soon as possible Date: Wed, 18 Jul 2018 14:15:59 +0900 (KST) Message-ID: <20180718.141559.1076017531577697883.davem@davemloft.net> References: <1531653191-6456-1-git-send-email-baoyou.xie@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: baoyou.xie@gmail.com, willemb@google.com, viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, pombredanne@nexb.com, tklauser@distanz.ch, matthew@mjdsystems.ca, netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: willemdebruijn.kernel@gmail.com Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org From: Willem de Bruijn 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.