Skip to content

Commit

Permalink
mptcp: try harder to borrow memory from subflow under pressure
Browse files Browse the repository at this point in the history
[ Upstream commit 72f9613 ]

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: 9c3f94e ("mptcp: add missing memory scheduling in the rx path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Paolo Abeni authored and gregkh committed Jun 23, 2021
1 parent 3b491dd commit 222ebed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/mptcp/protocol.c
Expand Up @@ -276,11 +276,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;
}

/* the skb map_seq accounts for the skb offset:
Expand Down

0 comments on commit 222ebed

Please sign in to comment.