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


Groups > linux.kernel > #1283440

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-04 00:10 +0100
Message-ID <qBLaF-34j-9@gated-at.bofh.it> (permalink)
References <qAWBc-42t-17@gated-at.bofh.it> <qBk0R-2jf-57@gated-at.bofh.it> <qBJBU-22d-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Date: Thu, 03 Dec 2015 21:24:17 +0000

> David Miller <davem@davemloft.net> writes:
>> 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?
> 
> As far as I can tell, yes. With the change, unix_dgram_recvmsg has a
> read loop looking like this:
> 
> 	last = NULL; /* not really necessary */
> 	timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
> 
> 	do {
> 		mutex_lock(&u->readlock);
> 
> 		skip = sk_peek_offset(sk, flags);
> 		skb = __skb_try_recv_datagram(sk, flags, &peeked, &skip, &err,
> 					      &last);
> 		if (skb)
> 			break;
> 
> 		mutex_unlock(&u->readlock);
> 
> 		if (err != -EAGAIN)
> 			break;
> 	} while (timeo &&
> 		 !__skb_wait_for_more_packets(sk, &err, &timeo, last));
> 
> u->readlock is only used to enforce serialized access while running code
> dealing with the peek offset. If there's currently nothing to receive,
> the mutex is dropped. Afterwards, non-blocking readers return with
> -EAGAIN and blocking readers go to sleep waiting for 'interesting
> events' via __skb_wait_for_more_packets without stuffing the mutex into
> a pocket and taking it with them: All non-blocking readers of a certain
> socket end up going to sleep via schedule_timeout call in the wait
> function, hence, each of them will be woken up once its timeout expires.

Great, thanks for the info.  I think you should submit this patch
formally.
--
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 | 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