Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1282242

Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg

From David Miller <davem@davemloft.net>
Newsgroups linux.kernel
Subject Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg
Date 2015-12-02 19:10 +0100
Message-ID <qBk0R-2jf-57@gated-at.bofh.it> (permalink)
References <qAhol-2Nl-1@gated-at.bofh.it> <qAWBc-42t-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Date: Tue, 01 Dec 2015 17:02:33 +0000

> Rainer Weikusat <rw@doppelsaurus.mobileactivedefense.com> 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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-12-01 18:10 +0100
  Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg David Miller <davem@davemloft.net> - 2015-12-02 19:10 +0100
    Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-12-03 22:30 +0100
      Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg Eric Dumazet <eric.dumazet@gmail.com> - 2015-12-03 22:50 +0100
      Re: [RFC PATCH] af_unix: fix entry locking in unix_dgram_recvmsg David Miller <davem@davemloft.net> - 2015-12-04 00:10 +0100

csiph-web