All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Florian Westphal <fw@strlen.de>, mptcp@lists.linux.dev
Subject: Re: [PATCH v2 mptcp-next 1/8] mptcp: enable busypoll from mptcp receive path
Date: Fri, 14 May 2021 11:57:30 +0200	[thread overview]
Message-ID: <20210514095730.GA30441@breakpoint.cc> (raw)
In-Reply-To: <e5bad85c6b9d560f30f094a1b55fa4e901170931.camel@redhat.com>

Paolo Abeni <pabeni@redhat.com> wrote:
> On Wed, 2021-05-12 at 12:04 +0200, Florian Westphal wrote:
> > Paolo Abeni <pabeni@redhat.com> wrote:
> > > On Tue, 2021-05-11 at 15:36 +0200, Florian Westphal wrote:
> > > > +	if (sk_can_busy_loop(sk) &&
> > > > +	    skb_queue_empty_lockless(&msk->receive_queue) &&
> > > > +	    skb_queue_empty_lockless(&sk->sk_receive_queue) &&
> > > > +	    inet_sk_state_load(sk) == TCP_ESTABLISHED)
> > > > +		sk_busy_loop(sk, nonblock);
> > > 
> > > If I understand the code correctly, here we need a valid sk-
> > > > sk_napi_id. That field is set by the TCP input path
> > > in tcp_finish_connect()/tcp_v{4,6}_do_rcv()/tcp_child_process() for the
> > > subflow ssk.
> > > 
> > > I think sk_napi_id is not currently available for the msk?!? 
> > > Copying it from the subflow requires some care, as the msk could end-up 
> > > busy polling on the 'wrong' napi instance ?!?
> > 
> > What about:
> > 
> > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > --- a/net/mptcp/protocol.c
> > +++ b/net/mptcp/protocol.c
> > @@ -303,6 +303,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
> >  		if (tail && mptcp_try_coalesce(sk, tail, skb))
> >  			return true;
> >  
> > +		sk_mark_napi_id_once(sk, skb);
> >  		skb_set_owner_r(skb, sk);
> >  		__skb_queue_tail(&sk->sk_receive_queue, skb);
> >  		return true;
> > 
> > This sets the napi id to one that provided the last mptcp-in-sequence skb.
> 
> I *think* the above sets napi it to the one provided by the first
> received skb.

Depends on wheter the receive queue is empty or not.

Its the most recent subflow that had activity.

> What about something as crazy as the following? not even build tested,
> but I hope it can illustrate the idea bettern than words.

I'm no longer convicend busypolling makes any sense with mptcp sockets,
see below.

> +	for (;;) {
> +		int nr, napi_id = napi_id_by_subflow_nr(sk, 0);
> +
> +		for (nr = 0; napi_id >= 0 ; napi_id = napi_id_by_subflow_nr(sk, ++nr)) }
> +			napi_busy_loop(napi_id, NULL, NULL,
> +			       READ_ONCE(sk->sk_prefer_busy_poll),
> +			       READ_ONCE(sk->sk_busy_poll_budget) ?: BUSY_POLL_BUDGET);
> +			if (skb_queue_empty_lockless(&sk->sk_receive_queue))
> +				return;

We would need a new conditional to early-terminate the busypoll loop.

Else we might be busypolling on napi instance 1 while another instance
just made a packet available.

Futhermore, we'd have to divide the budget among the napi instances to
avoid excess usage.

The way I see it busypoll should never increase latency, but with the
above, afaics, it would since we don't have a 1:1 mapping of mptcp
socket to a napi instance that we expect packets on.

The way I see it there are two options:
1. Ignore buyspoll requests, or.
2. Set the napi instance ID from __mptcp_move_skb().
   As soon as the instance changes (anoter subflow on different path),
   disable busypoll for that mptcp socket.

1) is simpler, 2) would still support busypoll for fallback mode and
for '1 flow' resp. 'multiple flows on same napi instance'.

The latter could happen if we assume server with single
link that serves clients with multiple uplinks.

  reply	other threads:[~2021-05-14  9:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 13:36 [PATCH v2 mptcp-next 0/8] add cmsg support to receive path Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 1/8] mptcp: enable busypoll from mptcp " Florian Westphal
2021-05-12  8:19   ` Paolo Abeni
2021-05-12  9:08     ` Florian Westphal
2021-05-12 10:04     ` Florian Westphal
2021-05-12 15:06       ` Paolo Abeni
2021-05-14  9:57         ` Florian Westphal [this message]
2021-05-14 10:35           ` Paolo Abeni
2021-05-14 10:50             ` Paolo Abeni
2021-05-11 13:36 ` [PATCH v2 mptcp-next 2/8] sock: expose so_timestamp options for mptcp Florian Westphal
2021-05-19  8:58   ` [sock] d1023bc19b: kernel-selftests.net.rxtimestamp.sh.fail kernel test robot
2021-05-19  8:58     ` kernel test robot
2021-05-11 13:36 ` [PATCH v2 mptcp-next 3/8] sock: expose so_timestamping options for mptcp Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 4/8] mptcp: sockopt: propagate timestamp request to subflows Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 5/8] mptcp: setsockopt: handle SOL_SOCKET in one place only Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 6/8] tcp: export timestamp helpers for mptcp Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 7/8] mptcp: receive path cmsg support Florian Westphal
2021-05-11 13:36 ` [PATCH v2 mptcp-next 8/8] selftests: mptcp_connect: add SO_TIMESTAMPNS " 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=20210514095730.GA30441@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.