[dpdk-dev] [PATCH 6/6] examples/vhost: add an option to enable Tx zero copy

Maxime Coquelin maxime.coquelin at redhat.com
Tue Aug 23 16:14:44 CEST 2016



On 08/23/2016 10:10 AM, Yuanhan Liu wrote:
> Add an option, --tx-zero-copy, to enable Tx zero copy.
>
> One thing worth noting while using Tx zero copy is the nb_tx_desc has
> to be small enough so that the eth driver will hit the mbuf free
> threshold easily and thus free mbuf more frequently.
>
> The reason behind that is, when Tx zero copy is enabled, guest Tx used
> vring will be updated only when corresponding mbuf is freed. If mbuf is
> not freed frequently, the guest Tx vring could be starved.
>
> Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> ---
>  examples/vhost/main.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 9974f0b..e3437ad 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -130,6 +130,7 @@ static uint32_t enable_tx_csum;
>  static uint32_t enable_tso;
>
>  static int client_mode;
> +static int tx_zero_copy;
>
>  /* Specify timeout (in useconds) between retries on RX. */
>  static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US;
> @@ -297,6 +298,17 @@ port_init(uint8_t port)
>
>  	rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
>  	tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
> +
> +	/*
> +	 * When Tx zero copy is enabled, guest Tx used vring will be updated
> +	 * only when corresponding mbuf is freed. Thus, the nb_tx_desc
> +	 * (tx_ring_size here) must be small enough so that the driver will
> +	 * hit the free threshold easily and free mbufs timely. Otherwise,
> +	 * guest Tx vring would be starved.
> +	 */
> +	if (tx_zero_copy)
> +		tx_ring_size = 64;

I have a concern about more complex applications, where the mbufs might
not be consumed sequentially.
If one mbuf gets stuck for a while, whereas all others are consumed,
we would face starvation.
For example, the packet is to be routed to a VM, which is paused,
and the routing thread keeps retrying to enqueue the packet for a while.

Anyway, this feature is optional and off by default, so having the
feature applied is not a blocker.

Thanks!
Maxime


More information about the dev mailing list