DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Wenwu Ma <wenwux.ma@intel.com>
Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, dev@dpdk.org,
	sunil.pai.g@intel.com, jiayu.hu@intel.com, yinan.wang@intel.com,
	xingguang.he@intel.com, xuan.ding@intel.com,
	cheng1.jiang@intel.com, yuanx.wang@intel.com
Subject: Re: [PATCH v4] vhost: support CPU copy for small packets
Date: Thu, 3 Oct 2024 19:22:46 -0700	[thread overview]
Message-ID: <20241003192246.4a83f3cd@hermes.local> (raw)
In-Reply-To: <20220829005658.84590-1-wenwux.ma@intel.com>

On Mon, 29 Aug 2022 08:56:58 +0800
Wenwu Ma <wenwux.ma@intel.com> wrote:

> Offloading small packets to DMA degrades throughput 10%~20%,
> and this is because DMA offloading is not free and DMA is not
> good at processing small packets. In addition, control plane
> packets are usually small, and assign those packets to DMA will
> significantly increase latency, which may cause timeout like
> TCP handshake packets. Therefore, this patch use CPU to perform
> small copies in vhost.
> 
> Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
> ---
> v4:
> * fix coding style issues
> v3:
> * compare threshold with entire packet length
> v2:
> * fix CI build error
> ---
>  lib/vhost/vhost.h      |  7 ++--
>  lib/vhost/virtio_net.c | 73 +++++++++++++++++++++++++++++++++---------
>  2 files changed, 62 insertions(+), 18 deletions(-)
> 
> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
> index 40fac3b7c6..8a7d90f737 100644
> --- a/lib/vhost/vhost.h
> +++ b/lib/vhost/vhost.h
> @@ -142,8 +142,10 @@ struct virtqueue_stats {
>   * iovec
>   */
>  struct vhost_iovec {
> -	void *src_addr;
> -	void *dst_addr;
> +	void *src_iov_addr;
> +	void *dst_iov_addr;
> +	void *src_virt_addr;
> +	void *dst_virt_addr;
>  	size_t len;
>  };
>  
> @@ -155,6 +157,7 @@ struct vhost_iov_iter {
>  	struct vhost_iovec *iov;
>  	/** number of iovec in this iterator */
>  	unsigned long nr_segs;
> +	unsigned long nr_len;
>  };
>  
>  struct async_dma_vchan_info {
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 35fa4670fd..cf796183a0 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -26,6 +26,8 @@
>  
>  #define MAX_BATCH_LEN 256
>  

> +#define CPU_COPY_THRESHOLD_LEN 256

Good idea.
This heuristic matches what Linux network drivers do to avoid
creating large buffers from small packets.

Patch no longer applies cleanly to main branch (after 2 years).

Also the copy threshold should be configurable via dev_args to allow
for testing and CPU differences.

      parent reply	other threads:[~2024-10-04  2:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12  6:45 [PATCH] " Wenwu Ma
2022-08-12  7:34 ` [PATCH v2] " Wenwu Ma
2022-08-26  5:31 ` [PATCH v3] " Wenwu Ma
2022-08-29  0:56 ` [PATCH v4] " Wenwu Ma
2022-09-07 14:47   ` Morten Brørup
2022-09-27  7:32     ` Ma, WenwuX
2022-09-27 10:45       ` Morten Brørup
2024-10-04  2:22   ` Stephen Hemminger [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=20241003192246.4a83f3cd@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=chenbo.xia@intel.com \
    --cc=cheng1.jiang@intel.com \
    --cc=dev@dpdk.org \
    --cc=jiayu.hu@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=sunil.pai.g@intel.com \
    --cc=wenwux.ma@intel.com \
    --cc=xingguang.he@intel.com \
    --cc=xuan.ding@intel.com \
    --cc=yinan.wang@intel.com \
    --cc=yuanx.wang@intel.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).