netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] mptcp: attempt coalescing when moving skbs to mptcp rx queue
@ 2020-05-25 21:41 Florian Westphal
  2020-05-27  3:29 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2020-05-25 21:41 UTC (permalink / raw)
  To: netdev; +Cc: mathew.j.martineau, pabeni, matthieu.baerts, Florian Westphal

We can try to coalesce skbs we take from the subflows rx queue with the
tail of the mptcp rx queue.

If successful, the skb head can be discarded early.

We can also free the skb extensions, we do not access them after this.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/mptcp/protocol.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d868b3d921fd..e07a5896fea4 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -144,12 +144,29 @@ static void __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
 			     unsigned int offset, size_t copy_len)
 {
 	struct sock *sk = (struct sock *)msk;
+	struct sk_buff *tail;
 
 	__skb_unlink(skb, &ssk->sk_receive_queue);
-	skb_set_owner_r(skb, sk);
-	__skb_queue_tail(&sk->sk_receive_queue, skb);
 
+	skb_ext_reset(skb);
+	skb_orphan(skb);
 	msk->ack_seq += copy_len;
+
+	tail = skb_peek_tail(&sk->sk_receive_queue);
+	if (offset == 0 && tail) {
+		bool fragstolen;
+		int delta;
+
+		if (skb_try_coalesce(tail, skb, &fragstolen, &delta)) {
+			kfree_skb_partial(skb, fragstolen);
+			atomic_add(delta, &sk->sk_rmem_alloc);
+			sk_mem_charge(sk, delta);
+			return;
+		}
+	}
+
+	skb_set_owner_r(skb, sk);
+	__skb_queue_tail(&sk->sk_receive_queue, skb);
 	MPTCP_SKB_CB(skb)->offset = offset;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] mptcp: attempt coalescing when moving skbs to mptcp rx queue
  2020-05-25 21:41 [PATCH net-next] mptcp: attempt coalescing when moving skbs to mptcp rx queue Florian Westphal
@ 2020-05-27  3:29 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-05-27  3:29 UTC (permalink / raw)
  To: fw; +Cc: netdev, mathew.j.martineau, pabeni, matthieu.baerts

From: Florian Westphal <fw@strlen.de>
Date: Mon, 25 May 2020 23:41:13 +0200

> We can try to coalesce skbs we take from the subflows rx queue with the
> tail of the mptcp rx queue.
> 
> If successful, the skb head can be discarded early.
> 
> We can also free the skb extensions, we do not access them after this.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>

Applied, thanks Florian.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-27  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 21:41 [PATCH net-next] mptcp: attempt coalescing when moving skbs to mptcp rx queue Florian Westphal
2020-05-27  3:29 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).