Skip to content

Commit 72f9613

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: try harder to borrow memory from subflow under pressure
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>
1 parent 22488e4 commit 72f9613

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎net/mptcp/protocol.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,13 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
280280

281281
/* try to fetch required memory from subflow */
282282
if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
283-
if (ssk->sk_forward_alloc < skb->truesize)
284-
goto drop;
285-
__sk_mem_reclaim(ssk, skb->truesize);
286-
if (!sk_rmem_schedule(sk, skb, skb->truesize))
283+
int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT;
284+
285+
if (ssk->sk_forward_alloc < amount)
287286
goto drop;
287+
288+
ssk->sk_forward_alloc -= amount;
289+
sk->sk_forward_alloc += amount;
288290
}
289291

290292
/* the skb map_seq accounts for the skb offset:

0 commit comments

Comments
 (0)