MPTCP Linux Development
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni at redhat.com>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [PATCH v4 7/7] mptcp: use mptcp backlog.
Date: Thu, 19 Nov 2020 09:36:39 +0100	[thread overview]
Message-ID: <bd206ee992b0a8bdfe7a23dd09d4a8492bc95704.camel@redhat.com> (raw)
In-Reply-To: 20201118231107.GB15137@breakpoint.cc

[-- Attachment #1: Type: text/plain, Size: 1951 bytes --]

Hello,

On Thu, 2020-11-19 at 00:11 +0100, Florian Westphal wrote:
> Paolo Abeni <pabeni(a)redhat.com> wrote:
> > @@ -2812,6 +2859,17 @@ static void mptcp_release_cb(struct sock *sk)
> >  {
> >  	unsigned long flags, nflags;
> >  
> > +	/* push_pending may touch wmem_reserved, do it before the later
> > +	 * cleanup
> > +	 */
> 
> Can you expand here a bit on why the lock break is needed & safe?
> 
> We still own the socket, so I think its safe, but I am not sure why its
> needed.  Only due to GFP_KERNEL alloc in mptcp_push_pending, or is there
> more to it?

mptcp_push_pending() acquires the subflow socket lock:

1) can't be invoked in atomic scope
2) abba deadlock with msk socket spinlock, since the rx datapath
acquires the msk socket spinlock while helding the subflow socket lock.
> 
> > +	set_bit(MPTCP_NOSPACE, &msk->flags);
> > +	smp_mb__after_atomic(); /* msk->flags is changed by write_space cb */
> 
> I'm not sure why the barrier is needed.  What load/store needs the ordering?

Maybe cargo-cult c&p on my side. Now MPTCP write poll code mirrors very
closely TCP's one, with s/MPTCP_NOSPACE/SOCK_NOSPACE/, and retains the
same barriers.

My understanding is that is needed in the following scenario:

BH - CPU0				User-space CPU1
<rx path>				<poll>

<free space>				<test write space>
<mb>					set_bit(...)
if test_bit(...)			<mb>
	sk_stream_write_space(sk)	<test write space>

without the memory barrier pairs the 2nd <test write space> could
actually miss the update done by <frees space> and test_bit can miss
the set_bit() perfomed on the other side due to reordering.

Looks like we currently lack the mb() on the rx side ;)

Additionally it would be better move the sk_stream_write_space() from
subflow_write_space af the end of mptcp_clean_una, where wspace is
actually freed.


> Maybe I'm blind -- nothing catches my eye either here or in
> subflow_write_space.


             reply	other threads:[~2020-11-19  8:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19  8:36 Paolo Abeni [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-19 11:09 [MPTCP] Re: [PATCH v4 7/7] mptcp: use mptcp backlog Paolo Abeni
2020-11-19  9:41 Florian Westphal
2020-11-18 23:11 Florian Westphal

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=bd206ee992b0a8bdfe7a23dd09d4a8492bc95704.camel@redhat.com \
    --to=mptcp@lists.linux.dev \
    /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