netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] skbuff: Add MSG_MORE flag to optimize large packet transmission
@ 2025-06-30  7:10 Feng Yang
  2025-07-03  8:48 ` Paolo Abeni
  0 siblings, 1 reply; 8+ messages in thread
From: Feng Yang @ 2025-06-30  7:10 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, willemb, almasrymina,
	kerneljasonxing, ebiggers, asml.silence, aleksander.lobakin,
	stfomichev, david.laight.linux
  Cc: yangfeng, netdev, linux-kernel

From: Feng Yang <yangfeng@kylinos.cn>

The "MSG_MORE" flag is added to improve the transmission performance of large packets.
The improvement is more significant for TCP, while there is a slight enhancement for UDP.

When using sockmap for forwarding, the average latency for different packet sizes
after sending 10,000 packets(TCP) is as follows:
size    old(us)         new(us)
512     56              55
1472    58              58
1600    106             81
3000    145             105
5000    182             125

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
---
Changes in v3:
- Use Msg_MORE flag. Thanks: Eric Dumazet, David Laight.
- Link to v2: https://lore.kernel.org/all/20250627094406.100919-1-yangfeng59949@163.com/

Changes in v2:
- Delete dynamic memory allocation, thanks: Paolo Abeni,Stanislav Fomichev.
- Link to v1: https://lore.kernel.org/all/20250623084212.122284-1-yangfeng59949@163.com/
---
 net/core/skbuff.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 85fc82f72d26..cd1ed96607a5 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3252,6 +3252,8 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset,
 		kv.iov_len = slen;
 		memset(&msg, 0, sizeof(msg));
 		msg.msg_flags = MSG_DONTWAIT | flags;
+		if (slen < len)
+			msg.msg_flags |= MSG_MORE;
 
 		iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &kv, 1, slen);
 		ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked,
@@ -3292,6 +3294,8 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset,
 					     flags,
 			};
 
+			if (slen < len)
+				msg.msg_flags |= MSG_MORE;
 			bvec_set_page(&bvec, skb_frag_page(frag), slen,
 				      skb_frag_off(frag) + offset);
 			iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1,
-- 
2.43.0


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

end of thread, other threads:[~2025-07-07  7:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  7:10 [PATCH v3] skbuff: Add MSG_MORE flag to optimize large packet transmission Feng Yang
2025-07-03  8:48 ` Paolo Abeni
2025-07-03 11:44   ` David Laight
2025-07-04  9:26     ` Feng Yang
2025-07-04 15:50       ` Paolo Abeni
2025-07-05  7:16         ` David Laight
2025-07-07  6:17         ` Feng Yang
2025-07-07  7:19           ` Eric Dumazet

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).