[dpdk-dev] [PATCH 2/3] vhost: optimize dequeue for small packets

Yuanhan Liu yuanhan.liu at linux.intel.com
Wed Jun 1 08:44:03 CEST 2016


On Wed, Jun 01, 2016 at 06:24:18AM +0000, Xie, Huawei wrote:
> On 5/3/2016 8:42 AM, Yuanhan Liu wrote:
> > Both current kernel virtio driver and DPDK virtio driver use at least
> > 2 desc buffer for Tx: the first for storing the header, and the others
> > for storing the data.
> 
> Tx could prepend some space for virtio net header whenever possible, so
> that it could use only one descriptor.

In such case, it will work as well: it will goto the "else" code path
then.

> Another thing is this doesn't reduce the check because you also add a check.

Actually, yes, it does save check. Before this patch, we have:

	while (not done yet) {
 	       if (desc_is_drain)
 	               ...;

 	       if (mbuf_is_full)
 	               ...;

 	       COPY();
	}

Note that the "while" check will be done twice, therefore, it's 4
checks in total. After this patch, it would be:

	if (virtio_net_hdr_takes_one_desc)
		...

	while (1) {
		COPY();

		if (desc_is_drain) {
			break if done;
			...;
		}

		if (mbuf_is_full {
			/* small packets will bypass this check */
			....;
		}
	}

So, for small packets, it takes 2 checks only, which actually saves
2 checks.

	--yliu


More information about the dev mailing list