From: Paolo Abeni Date: Thu, 30 Jun 2022 22:17:56 +0000 (-0700) Subject: mptcp: refine memory scheduling X-Git-Tag: v5.18.18~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=022b2d2c4ffa073acce031b9d5dcb5904e988948;p=thirdparty%2Fkernel%2Fstable.git mptcp: refine memory scheduling commit 69d93daec026cdda98e29e8edb12534bfa5b1a9b upstream. Similar to commit 7c80b038d23e ("net: fix sk_wmem_schedule() and sk_rmem_schedule() errors"), let the MPTCP receive path schedule exactly the required amount of memory. Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 07b5a2044cab4..9c25e6a9a2795 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -323,9 +323,10 @@ static bool mptcp_rmem_schedule(struct sock *sk, struct sock *ssk, int size) struct mptcp_sock *msk = mptcp_sk(sk); int amt, amount; - if (size < msk->rmem_fwd_alloc) + if (size <= msk->rmem_fwd_alloc) return true; + size -= msk->rmem_fwd_alloc; amt = sk_mem_pages(size); amount = amt << SK_MEM_QUANTUM_SHIFT; msk->rmem_fwd_alloc += amount;