From: Mat Martineau <martineau@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [mptcp-next v2 3/7] mptcp: fix potential wake-up event loss
Date: Thu, 15 Feb 2024 14:20:03 -0800 (PST) [thread overview]
Message-ID: <27696500-0456-ef2d-164b-d6c7a30a459e@kernel.org> (raw)
In-Reply-To: <78924a15f3d86f989fa286f10ef88670b790eb89.1707739536.git.pabeni@redhat.com>
On Mon, 12 Feb 2024, Paolo Abeni wrote:
> After the blamed commit below, the send buffer auto-tuning can
> happen after that the mptcp_propagate_sndbuf() completes - via
> the delegated action infrastructure.
>
> We must check for write space even after such change or we risk
> missing the wake-up event.
>
> Fixes: 8005184fd1ca ("mptcp: refactor sndbuf auto-tuning")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> net/mptcp/protocol.h | 27 ++++++++++++++++++++-------
> 1 file changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 486fff865803..2e197262a42e 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -797,6 +797,16 @@ static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk)
> READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt);
> }
>
> +static inline void mptcp_write_space(struct sock *sk)
> +{
> + if (sk_stream_is_writeable(sk)) {
> + /* pairs with memory barrier in mptcp_poll */
> + smp_mb();
> + if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags))
> + sk_stream_write_space(sk);
> + }
> +}
> +
> static inline void __mptcp_sync_sndbuf(struct sock *sk)
> {
> struct mptcp_subflow_context *subflow;
> @@ -815,6 +825,7 @@ static inline void __mptcp_sync_sndbuf(struct sock *sk)
>
> /* the msk max wmem limit is <nr_subflows> * tcp wmem[2] */
> WRITE_ONCE(sk->sk_sndbuf, new_sndbuf);
> + mptcp_write_space(sk);
> }
>
> /* The called held both the msk socket and the subflow socket locks,
> @@ -845,14 +856,16 @@ static inline void mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
> local_bh_enable();
> }
>
> -static inline void mptcp_write_space(struct sock *sk)
> +static inline void __mptcp_sync_sndnxt(struct sock *sk, u64 new_snd_nxt)
Hi Paolo -
I think you missed my comment on this in v1, __mptcp_sync_sndnxt() isn't
called anywhere.
- Mat
> {
> - if (sk_stream_is_writeable(sk)) {
> - /* pairs with memory barrier in mptcp_poll */
> - smp_mb();
> - if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags))
> - sk_stream_write_space(sk);
> - }
> + struct mptcp_sock *msk = mptcp_sk(sk);
> +
> + if (!after64(new_snd_nxt, msk->snd_nxt))
> + return;
> +
> + msk->bytes_sent += new_snd_nxt - msk->snd_nxt;
> + WRITE_ONCE(msk->snd_nxt, new_snd_nxt);
> + mptcp_write_space(sk);
> }
>
> void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags);
> --
> 2.43.0
>
>
>
next prev parent reply other threads:[~2024-02-15 22:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 15:18 [mptcp-next v2 0/7] mptcp: implement TCP_NOTSENT_LOWAT support Paolo Abeni
2024-02-12 15:18 ` [mptcp-next v2 1/7] mptcp: push ad DSS boundaries Paolo Abeni
2024-02-15 22:33 ` Mat Martineau
2024-02-12 15:18 ` [mptcp-next v2 2/7] mptcp: fix snd_wnd initialization for passive socket Paolo Abeni
2024-02-12 15:18 ` [mptcp-next v2 3/7] mptcp: fix potential wake-up event loss Paolo Abeni
2024-02-15 22:20 ` Mat Martineau [this message]
2024-02-16 9:39 ` Paolo Abeni
2024-02-12 15:18 ` [mptcp-next v2 4/7] mptcp: cleanup writer wake-up Paolo Abeni
2024-02-12 15:19 ` [mptcp-next v2 5/7] mptcp: avoid some duplicate code in socket option handling Paolo Abeni
2024-02-12 15:19 ` [mptcp-next v2 6/7] mptcp: implement TCP_NOTSENT_LOWAT support Paolo Abeni
2024-02-15 22:31 ` Mat Martineau
2024-02-12 15:19 ` [mptcp-next v2 7/7] mptcp: cleanup SOL_TCP handling Paolo Abeni
2024-02-12 16:10 ` mptcp: cleanup SOL_TCP handling: Tests Results MPTCP CI
2024-02-12 16:28 ` MPTCP CI
2024-02-13 9:53 ` MPTCP CI
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=27696500-0456-ef2d-164b-d6c7a30a459e@kernel.org \
--to=martineau@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox