From: Jason Wang <jasowang@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>, netdev@vger.kernel.org
Cc: "Song Liu" <songliubraving@fb.com>,
"Martin KaFai Lau" <kafai@fb.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Björn Töpel" <bjorn@kernel.org>,
"dust . li" <dust.li@linux.alibaba.com>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
bpf@vger.kernel.org, virtualization@lists.linux-foundation.org,
"David S. Miller" <davem@davemloft.net>,
"Magnus Karlsson" <magnus.karlsson@intel.com>
Subject: Re: [PATCH net-next v5 15/15] virtio-net: xsk zero copy xmit kick by threshold
Date: Thu, 17 Jun 2021 11:08:34 +0800 [thread overview]
Message-ID: <7dbdb429-edda-9f33-fbfa-bb128c5e3eca@redhat.com> (raw)
In-Reply-To: <20210610082209.91487-16-xuanzhuo@linux.alibaba.com>
在 2021/6/10 下午4:22, Xuan Zhuo 写道:
> After testing, the performance of calling kick every time is not stable.
> And if all the packets are sent and kicked again, the performance is not
> good. So add a module parameter to specify how many packets are sent to
> call a kick.
>
> 8 is a relatively stable value with the best performance.
>
> Here is the pps of the test of xsk_kick_thr under different values (from
> 1 to 64).
>
> thr PPS thr PPS thr PPS
> 1 2924116.74247 | 23 3683263.04348 | 45 2777907.22963
> 2 3441010.57191 | 24 3078880.13043 | 46 2781376.21739
> 3 3636728.72378 | 25 2859219.57656 | 47 2777271.91304
> 4 3637518.61468 | 26 2851557.9593 | 48 2800320.56575
> 5 3651738.16251 | 27 2834783.54408 | 49 2813039.87599
> 6 3652176.69231 | 28 2847012.41472 | 50 3445143.01839
> 7 3665415.80602 | 29 2860633.91304 | 51 3666918.01281
> 8 3665045.16555 | 30 2857903.5786 | 52 3059929.2709
I wonder what's the number for the case of non zc xsk?
Thanks
> 9 3671023.2401 | 31 2835589.98963 | 53 2831515.21739
> 10 3669532.23274 | 32 2862827.88706 | 54 3451804.07204
> 11 3666160.37749 | 33 2871855.96696 | 55 3654975.92385
> 12 3674951.44813 | 34 3434456.44816 | 56 3676198.3188
> 13 3667447.57331 | 35 3656918.54177 | 57 3684740.85619
> 14 3018846.0503 | 36 3596921.16722 | 58 3060958.8594
> 15 2792773.84505 | 37 3603460.63903 | 59 2828874.57191
> 16 3430596.3602 | 38 3595410.87666 | 60 3459926.11027
> 17 3660525.85806 | 39 3604250.17819 | 61 3685444.47599
> 18 3045627.69054 | 40 3596542.28428 | 62 3049959.0809
> 19 2841542.94177 | 41 3600705.16054 | 63 2806280.04013
> 20 2830475.97348 | 42 3019833.71191 | 64 3448494.3913
> 21 2845655.55789 | 43 2752951.93264 |
> 22 3450389.84365 | 44 2753107.27164 |
>
> It can be found that when the value of xsk_kick_thr is relatively small,
> the performance is not good, and when its value is greater than 13, the
> performance will be more irregular and unstable. It looks similar from 3
> to 13, I chose 8 as the default value.
>
> The test environment is qemu + vhost-net. I modified vhost-net to drop
> the packets sent by vm directly, so that the cpu of vm can run higher.
> By default, the processes in the vm and the cpu of softirqd are too low,
> and there is no obvious difference in the test data.
>
> During the test, the cpu of softirq reached 100%. Each xsk_kick_thr was
> run for 300s, the pps of every second was recorded, and the average of
> the pps was finally taken. The vhost process cpu on the host has also
> reached 100%.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
> ---
> drivers/net/virtio/virtio_net.c | 1 +
> drivers/net/virtio/xsk.c | 18 ++++++++++++++++--
> drivers/net/virtio/xsk.h | 2 ++
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_net.c b/drivers/net/virtio/virtio_net.c
> index 9503133e71f0..dfe509939b45 100644
> --- a/drivers/net/virtio/virtio_net.c
> +++ b/drivers/net/virtio/virtio_net.c
> @@ -14,6 +14,7 @@ static bool csum = true, gso = true, napi_tx = true;
> module_param(csum, bool, 0444);
> module_param(gso, bool, 0444);
> module_param(napi_tx, bool, 0644);
> +module_param(xsk_kick_thr, int, 0644);
>
> /* FIXME: MTU in config. */
> #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
> diff --git a/drivers/net/virtio/xsk.c b/drivers/net/virtio/xsk.c
> index 3973c82d1ad2..2f3ba6ab4798 100644
> --- a/drivers/net/virtio/xsk.c
> +++ b/drivers/net/virtio/xsk.c
> @@ -5,6 +5,8 @@
>
> #include "virtio_net.h"
>
> +int xsk_kick_thr = 8;
> +
> static struct virtio_net_hdr_mrg_rxbuf xsk_hdr;
>
> static struct virtnet_xsk_ctx *virtnet_xsk_ctx_get(struct virtnet_xsk_ctx_head *head)
> @@ -455,6 +457,7 @@ static int virtnet_xsk_xmit_batch(struct send_queue *sq,
> struct xdp_desc desc;
> int err, packet = 0;
> int ret = -EAGAIN;
> + int need_kick = 0;
>
> while (budget-- > 0) {
> if (sq->vq->num_free < 2 + MAX_SKB_FRAGS) {
> @@ -475,11 +478,22 @@ static int virtnet_xsk_xmit_batch(struct send_queue *sq,
> }
>
> ++packet;
> + ++need_kick;
> + if (need_kick > xsk_kick_thr) {
> + if (virtqueue_kick_prepare(sq->vq) &&
> + virtqueue_notify(sq->vq))
> + ++stats->kicks;
> +
> + need_kick = 0;
> + }
> }
>
> if (packet) {
> - if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq))
> - ++stats->kicks;
> + if (need_kick) {
> + if (virtqueue_kick_prepare(sq->vq) &&
> + virtqueue_notify(sq->vq))
> + ++stats->kicks;
> + }
>
> *done += packet;
> stats->xdp_tx += packet;
> diff --git a/drivers/net/virtio/xsk.h b/drivers/net/virtio/xsk.h
> index fe22cf78d505..4f0f4f9cf23b 100644
> --- a/drivers/net/virtio/xsk.h
> +++ b/drivers/net/virtio/xsk.h
> @@ -7,6 +7,8 @@
>
> #define VIRTNET_XSK_BUFF_CTX ((void *)(unsigned long)~0L)
>
> +extern int xsk_kick_thr;
> +
> /* When xsk disable, under normal circumstances, the network card must reclaim
> * all the memory that has been sent and the memory added to the rq queue by
> * destroying the queue.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-06-17 3:08 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 8:21 [PATCH net-next v5 00/15] virtio-net: support xdp socket zero copy Xuan Zhuo
2021-06-10 8:21 ` [PATCH net-next v5 01/15] netdevice: priv_flags extend to 64bit Xuan Zhuo
2021-06-10 8:21 ` [PATCH net-next v5 02/15] netdevice: add priv_flags IFF_NOT_USE_DMA_ADDR Xuan Zhuo
2021-06-10 8:21 ` [PATCH net-next v5 03/15] virtio-net: " Xuan Zhuo
2021-06-16 9:27 ` Jason Wang
2021-06-16 10:27 ` Xuan Zhuo
2021-06-10 8:21 ` [PATCH net-next v5 04/15] xsk: XDP_SETUP_XSK_POOL support option IFF_NOT_USE_DMA_ADDR Xuan Zhuo
2021-06-10 8:21 ` [PATCH net-next v5 05/15] virtio: support virtqueue_detach_unused_buf_ctx Xuan Zhuo
2021-06-10 8:22 ` [PATCH net-next v5 06/15] virtio-net: unify the code for recycling the xmit ptr Xuan Zhuo
2021-06-16 2:42 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 07/15] virtio-net: standalone virtnet_aloc_frag function Xuan Zhuo
2021-06-16 2:45 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 08/15] virtio-net: split the receive_mergeable function Xuan Zhuo
2021-06-16 7:33 ` Jason Wang
2021-06-16 7:52 ` Xuan Zhuo
2021-06-10 8:22 ` [PATCH net-next v5 09/15] virtio-net: virtnet_poll_tx support budget check Xuan Zhuo
2021-06-10 8:22 ` [PATCH net-next v5 10/15] virtio-net: independent directory Xuan Zhuo
2021-06-16 7:34 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 11/15] virtio-net: move to virtio_net.h Xuan Zhuo
2021-06-16 7:35 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 12/15] virtio-net: support AF_XDP zc tx Xuan Zhuo
2021-06-16 9:26 ` Jason Wang
2021-06-16 10:19 ` Xuan Zhuo
2021-06-16 12:51 ` Jason Wang
2021-06-16 12:57 ` Xuan Zhuo
2021-06-17 2:36 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 13/15] virtio-net: support AF_XDP zc rx Xuan Zhuo
2021-06-17 3:23 ` Jason Wang
2021-06-17 5:53 ` Xuan Zhuo
2021-06-17 6:03 ` Jason Wang
2021-06-17 6:37 ` Xuan Zhuo
2021-06-17 6:58 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 14/15] virtio-net: xsk direct xmit inside xsk wakeup Xuan Zhuo
2021-06-17 3:07 ` Jason Wang
2021-06-17 5:55 ` Xuan Zhuo
2021-06-17 6:01 ` Jason Wang
2021-06-10 8:22 ` [PATCH net-next v5 15/15] virtio-net: xsk zero copy xmit kick by threshold Xuan Zhuo
2021-06-17 3:08 ` Jason Wang [this message]
2021-06-17 5:56 ` Xuan Zhuo
2021-06-17 6:00 ` Jason Wang
2021-06-17 6:43 ` Xuan Zhuo
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=7dbdb429-edda-9f33-fbfa-bb128c5e3eca@redhat.com \
--to=jasowang@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).