From: Feng Yang When using sockmap for forwarding, the average latency for different packet sizes after sending 10,000 packets 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 Signed-off-by: Feng Yang --- Changes in v4: - limiting MSG_MORE hint to TCP. Thanks: Paolo Abeni, David Laight, Eric Dumazet. - Link to v3: https://lore.kernel.org/all/20250630071029.76482-1-yangfeng59949@163.com/ 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 85fc82f72d26..b8da621f1552 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3235,6 +3235,7 @@ typedef int (*sendmsg_func)(struct sock *sk, struct msghdr *msg); static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len, sendmsg_func sendmsg, int flags) { + int more_hint = sk_is_tcp(sk) ? MSG_MORE : 0; unsigned int orig_len = len; struct sk_buff *head = skb; unsigned short fragidx; @@ -3252,6 +3253,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 |= more_hint; iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &kv, 1, slen); ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked, @@ -3292,6 +3295,8 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, flags, }; + if (slen < len) + msg.msg_flags |= more_hint; 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