From: David Miller <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
Date: Thu, 03 Dec 2015 18:06:36 -0500 (EST) [thread overview]
Message-ID: <20151203.180636.1484783292398481186.davem@davemloft.net> (raw)
In-Reply-To: <87zixrusxq.fsf@doppelsaurus.mobileactivedefense.com>
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.
prev parent reply other threads:[~2015-12-03 23:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 20:59 Rainer Weikusat
2015-12-01 17:02 ` Rainer Weikusat
2015-12-02 18:02 ` David Miller
2015-12-03 21:24 ` Rainer Weikusat
2015-12-03 21:47 ` Eric Dumazet
2015-12-03 23:06 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151203.180636.1484783292398481186.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rweikusat@mobileactivedefense.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®