diff mbox series

[net] mptcp: add missing memory scheduling in the rx path

Message ID f6143a6193a083574f11b00dbf7b5ad151bc4ff4.1603810630.git.pabeni@redhat.com
State Accepted
Delegated to: David Miller
Headers show
Series [net] mptcp: add missing memory scheduling in the rx path | expand

Checks

Context Check Description
jkicinski/cover_letter success Link
jkicinski/fixes_present success Link
jkicinski/patch_count success Link
jkicinski/tree_selection success Clearly marked for net
jkicinski/subject_prefix success Link
jkicinski/source_inline success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/module_param success Was 0 now: 0
jkicinski/build_32bit fail Errors and warnings before: 7 this patch: 7
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/verify_fixes success Link
jkicinski/checkpatch fail Link
jkicinski/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
jkicinski/header_inline success Link
jkicinski/stable success Stable not CCed

Commit Message

Paolo Abeni Oct. 27, 2020, 2:59 p.m. UTC
When moving the skbs from the subflow into the msk receive
queue, we must schedule there the required amount of memory.

Try to borrow the required memory from the subflow, if needed,
so that we leverage the existing TCP heuristic.

Fixes: 6771bfd9ee24 ("mptcp: update mptcp ack sequence from work queue")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Mat Martineau Oct. 27, 2020, 10:46 p.m. UTC | #1
On Tue, 27 Oct 2020, Paolo Abeni wrote:

> When moving the skbs from the subflow into the msk receive
> queue, we must schedule there the required amount of memory.
>
> Try to borrow the required memory from the subflow, if needed,
> so that we leverage the existing TCP heuristic.
>
> Fixes: 6771bfd9ee24 ("mptcp: update mptcp ack sequence from work queue")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> net/mptcp/protocol.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>

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

--
Mat Martineau
Intel
Jakub Kicinski Oct. 29, 2020, 6:29 p.m. UTC | #2
On Tue, 27 Oct 2020 15:46:11 -0700 (PDT) Mat Martineau wrote:
> On Tue, 27 Oct 2020, Paolo Abeni wrote:
> > When moving the skbs from the subflow into the msk receive
> > queue, we must schedule there the required amount of memory.
> >
> > Try to borrow the required memory from the subflow, if needed,
> > so that we leverage the existing TCP heuristic.
> >
> > Fixes: 6771bfd9ee24 ("mptcp: update mptcp ack sequence from work queue")
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> 
> Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 185dacb39781..e7419fd15d84 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -274,6 +274,15 @@  static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
 	skb_ext_reset(skb);
 	skb_orphan(skb);
 
+	/* 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))
+			goto drop;
+	}
+
 	/* the skb map_seq accounts for the skb offset:
 	 * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq
 	 * value
@@ -301,6 +310,7 @@  static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
 	 * will retransmit as needed, if needed.
 	 */
 	MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_DUPDATA);
+drop:
 	mptcp_drop(sk, skb);
 	return false;
 }