From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbaENSls (ORCPT ); Wed, 14 May 2014 14:41:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56763 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbaENSlr (ORCPT ); Wed, 14 May 2014 14:41:47 -0400 Date: Wed, 14 May 2014 20:40:59 +0200 From: Oleg Nesterov To: David Miller Cc: Peter Zijlstra , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: net/ && prepare_to_wait_exclusive() Message-ID: <20140514184059.GA9730@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I know almost nothing about networking and of course I do not understand this code. So I can be easily wrong, but (at least) unix_wait_for_peer() looks wrong wrt prepare_to_wait_exclusive(), and ignoring the potential optimizations it needs - finish_wait(&u->peer_wait, &wait); + abort_exclusive_wait(..., TASK_INTERRUPTIBLE, NULL); change? Suppose that unix_recvq_full(X) == true and 2 threads, T1 and T2, are sleeping in unix_dgram_sendmsg(). Another thread does read(X) and this empties ->sk_receive_queue so that the next read(X) will block. We should wake up at least one thread. The reader does wake_up_interruptible_sync_poll() and this is __wake_up_common(nr_exclusive => 1), so this (say) wakes T1 up. Suppose that this wake_up() races with (to simplify) SIGKILL and thus T1 writes nothing and exits. Now, the reader does another read(X) and blocks, ->sk_receive_queue is empty, we have the writer T2 but it is still blocked too? Or I completely misread this code? (On a related note... looks like ___wait_event() is not complicated^W clever enough to implement wait_event_interruptible_exclusive_timeout) Oleg.