All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net] mptcp: try harder to borrow memory from subflow under pressure
Date: Wed, 26 May 2021 21:17:13 -0700 (PDT)	[thread overview]
Message-ID: <e4ed3091-8734-ff3f-89fd-28ecc5981d5e@linux.intel.com> (raw)
In-Reply-To: <bc6471c8f7444b89e7e5f6c8f7713972477fda36.1622045437.git.pabeni@redhat.com>

On Wed, 26 May 2021, Paolo Abeni wrote:

> If the host is under sever memory pressure, and RX forward
> memory allocation for the msk fails, we try to borrow the
> required memory from the ingress subflow.
>
> The current attempt is a bit flaky: if skb->truesize is less
> than SK_MEM_QUANTUM, the ssk will not release any memory, and
> the next schedule will fail again.
>
> Instead, directly move the required amount of pages from the
> ssk to the msk, if available
>
> Fixes: 9c3f94e1681b ("mptcp: add missing memory scheduling in the rx path")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> net/mptcp/protocol.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index bb029dd4ff5e..785e74c13b3c 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -286,11 +286,13 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
>
> 	/* try to fetch required memory from subflow */
> 	if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
> -		if (ssk->sk_forward_alloc < skb->truesize)
> -			goto drop;
> -		__sk_mem_reclaim(ssk, skb->truesize);
> -		if (!sk_rmem_schedule(sk, skb, skb->truesize))
> +		int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT;
> +
> +		if (ssk->sk_forward_alloc < amount)
> 			goto drop;
> +
> +		ssk->sk_forward_alloc -= amount;
> +		sk->sk_forward_alloc += amount;
> 	}
>
> 	has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp;
> -- 
> 2.26.3

Looks ok to me - the memory will be reclaimed from the msk later, if I 
understand correctly.

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

--
Mat Martineau
Intel

  reply	other threads:[~2021-05-27  4:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 16:10 [PATCH mptcp-net] mptcp: try harder to borrow memory from subflow under pressure Paolo Abeni
2021-05-27  4:17 ` Mat Martineau [this message]
2021-05-27  9:05   ` Paolo Abeni
2021-06-04 19:34 ` Matthieu Baerts

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=e4ed3091-8734-ff3f-89fd-28ecc5981d5e@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --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.