netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Wei Wang <weiwan@google.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Martin KaFai Lau <kafai@fb.com>,
	Hannes Frederic Sowa <hannes@stressinduktion.org>,
	Julian Anastasov <ja@ssi.bg>
Subject: Re: [RFT Patch net 1/2] ipv6: invalidate the socket cached route on pmtu events if possible
Date: Mon, 28 Mar 2016 15:34:50 -0700	[thread overview]
Message-ID: <CAM_iQpWDrR_z59UkCpSKKCowLmxZimSnQv-4SfbXRxN6tvQXSw@mail.gmail.com> (raw)
In-Reply-To: <1458929477.6473.47.camel@edumazet-glaptop3.roam.corp.google.com>

On Fri, Mar 25, 2016 at 11:11 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Fri, 2016-03-25 at 10:17 -0700, Cong Wang wrote:
>
>> 1) sock lock protects the whole update: the whole check, update, recheck,
>> set logic, to make sure another CPU will not do the same to the same socket
>> at the same time.
>>
>> 2) the dst itself is safe, because it is always refcounted, and we use xchg()
>> to change the pointer in sk_dst_cache.
>>
>> Or am I still missing anything here?
>
> As TCP always lock the socket before doing its heavy stuff,
> it can use a variant of sk_dst_cache manipulations that do not use extra
> atomic operations.
>
> But UDP gets xchg() to safely exchange sk_dst_cache, because we do not
> feel locking the socket is needed for UDP for typical uses (! cork)
>
> If you hold the socket lock in ICMP handler, then it would be
> inconsistent with udp sendmsg() where we do not hold the socket lock.
>
> Since I believe udp sendmsg() is fine, I do believe you do not need to
> lock the socket, and then care about socket being owned by the user.

I see, seems the whole update logic is safe to become lock-free, then
commit 8141ed9fcedb278f4a3a78680591bef1e55f75fb can be just
reverted.

OTOH, other bh_lock_sock() callers need it to update queues etc.,
here we only need to check and update one single pointer in sk.

Steffen?

Thanks.

      reply	other threads:[~2016-03-28 22:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 19:25 [RFT Patch net 1/2] ipv6: invalidate the socket cached route on pmtu events if possible Cong Wang
2016-03-24 19:25 ` [RFT Patch net 2/2] ipv6: add a socket release callback for datagram sockets Cong Wang
2016-03-24 19:40   ` Cong Wang
2016-03-24 20:35 ` [RFT Patch net 1/2] ipv6: invalidate the socket cached route on pmtu events if possible Eric Dumazet
2016-03-24 21:38   ` Wei Wang
2016-03-25  0:15   ` Cong Wang
2016-03-25  1:51     ` Eric Dumazet
2016-03-25 17:17       ` Cong Wang
2016-03-25 18:11         ` Eric Dumazet
2016-03-28 22:34           ` Cong Wang [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=CAM_iQpWDrR_z59UkCpSKKCowLmxZimSnQv-4SfbXRxN6tvQXSw@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=ja@ssi.bg \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=weiwan@google.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;
as well as URLs for NNTP newsgroup(s).