From: Feng Yang <yangfeng59949@163.com>
To: david.laight.linux@gmail.com
Cc: aleksander.lobakin@intel.com, almasrymina@google.com,
asml.silence@gmail.com, davem@davemloft.net, ebiggers@google.com,
edumazet@google.com, horms@kernel.org, kerneljasonxing@gmail.com,
kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com, stfomichev@gmail.com,
willemb@google.com, yangfeng59949@163.com, yangfeng@kylinos.cn
Subject: Re: [PATCH v2] skbuff: Improve the sending efficiency of __skb_send_sock
Date: Mon, 30 Jun 2025 14:42:06 +0800 [thread overview]
Message-ID: <20250630064206.70948-1-yangfeng59949@163.com> (raw)
In-Reply-To: <20250629123339.0dd73fb1@pumpkin>
On Fri, 27 Jun 2025 03:23:24 -0700 Eric Dumazet <edumazet@google.com> wrote:
> On Fri, Jun 27, 2025 at 3:19 AM Eric Dumazet <edumazet@google.com> wrote:
> >
> > On Fri, Jun 27, 2025 at 2:44 AM Feng Yang <yangfeng59949@163.com> wrote:
> > >
> > > From: Feng Yang <yangfeng@kylinos.cn>
> > >
> > > By aggregating skb data into a bvec array for transmission, when using sockmap to forward large packets,
> > > what previously required multiple transmissions now only needs a single transmission, which significantly enhances performance.
> > > For small packets, the performance remains comparable to the original level.
> > >
> > > 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 79
> > > 3000 145 108
> > > 5000 182 123
> > >
> > > Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
> >
> > Instead of changing everything, have you tried strategically adding
> > MSG_MORE in this function ?
>
> Untested patch:
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index d6420b74ea9c6a9c53a7c16634cce82a1cd1bbd3..b0f5e8898fdf450129948d829240b570f3cbf9eb
> 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,
After testing, there is a performance improvement for large packets in both TCP and UDP.
Thanks.
prev parent reply other threads:[~2025-06-30 6:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 9:44 Feng Yang
2025-06-27 10:19 ` Eric Dumazet
2025-06-27 10:23 ` Eric Dumazet
2025-06-29 11:33 ` David Laight
2025-06-30 6:42 ` Feng Yang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250630064206.70948-1-yangfeng59949@163.com \
--to=yangfeng59949@163.com \
--cc=aleksander.lobakin@intel.com \
--cc=almasrymina@google.com \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=ebiggers@google.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stfomichev@gmail.com \
--cc=willemb@google.com \
--cc=yangfeng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®