Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933657AbbLBSCu (ORCPT ); Wed, 2 Dec 2015 13:02:50 -0500 Received: from shards.monkeyblade.net ([149.20.54.216]:45550 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932947AbbLBSCs (ORCPT ); Wed, 2 Dec 2015 13:02:48 -0500 Date: Wed, 02 Dec 2015 13:02:44 -0500 (EST) Message-Id: <20151202.130244.140973474498435711.davem@davemloft.net> To: rweikusat@mobileactivedefense.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg From: David Miller In-Reply-To: <871tb6nlue.fsf@doppelsaurus.mobileactivedefense.com> References: <87h9k41pyq.fsf@doppelsaurus.mobileactivedefense.com> <871tb6nlue.fsf@doppelsaurus.mobileactivedefense.com> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 02 Dec 2015 10:02:48 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1697 Lines: 41 From: Rainer Weikusat Date: Tue, 01 Dec 2015 17:02:33 +0000 > Rainer Weikusat writes: > > [...] > >> Insofar I understand the comment in this code block correctly, >> >> err = mutex_lock_interruptible(&u->readlock); >> if (unlikely(err)) { >> /* recvmsg() in non blocking mode is supposed to return -EAGAIN >> * sk_rcvtimeo is not honored by mutex_lock_interruptible() >> */ >> err = noblock ? -EAGAIN : -ERESTARTSYS; >> goto out; >> } >> >> setting a receive timeout for an AF_UNIX datagram socket also doesn't >> work as intended because of this: In case of n readers with the same >> timeout, the nth reader will end up blocking n times the timeout. > > Test program which confirms this. It starts four concurrent reads on the > same socket with a receive timeout of 3s. This means the whole program > should take a little more than 3s to execute as each read should time > out at about the same time. But it takes 12s instead as the reads > pile up on the readlock mutex and each then gets its own timeout once it > could enter the receive loop. I'm fine with your changes. So with your patch, the "N * timeout" behavior, where N is the number of queues reading threads, no longer occurs? Do they all now properly get released at the appropriate timeout? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/