DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Balazs Nemeth <bnemeth@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v2] vhost: allocate and free packets in bulk in Tx split
Date: Tue, 8 Jun 2021 06:05:29 +0000	[thread overview]
Message-ID: <MN2PR11MB40633D8B6E0F78DFD1064A019C379@MN2PR11MB4063.namprd11.prod.outlook.com> (raw)
In-Reply-To: <c52e90b4ae97ab218c5ced938a27fca9db61ff72.1622808738.git.bnemeth@redhat.com>

Hi Balazs,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Balazs Nemeth
> Sent: Friday, June 4, 2021 8:14 PM
> To: bnemeth@redhat.com; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; david.marchand@redhat.com
> Subject: [dpdk-dev] [PATCH v2] vhost: allocate and free packets in bulk in Tx
> split
> 
> Same idea as commit a287ac28919d ("vhost: allocate and free packets
> in bulk in Tx packed"), allocate and free packets in bulk. Also remove
> the unused function virtio_dev_pktmbuf_alloc.
> 
> Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>

I checked history and I find Maxime added his R-by? Better
add his R-by in commit log for new version 😊

> ---
>  lib/vhost/virtio_net.c | 37 ++++++++-----------------------------
>  1 file changed, 8 insertions(+), 29 deletions(-)
> 
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 8da8a86a10..fa387b5ff4 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -2670,32 +2670,6 @@ virtio_dev_pktmbuf_prep(struct virtio_net *dev, struct
> rte_mbuf *pkt,
>  	return -1;
>  }
> 
> -/*
> - * Allocate a host supported pktmbuf.
> - */
> -static __rte_always_inline struct rte_mbuf *
> -virtio_dev_pktmbuf_alloc(struct virtio_net *dev, struct rte_mempool *mp,
> -			 uint32_t data_len)
> -{
> -	struct rte_mbuf *pkt = rte_pktmbuf_alloc(mp);
> -
> -	if (unlikely(pkt == NULL)) {
> -		VHOST_LOG_DATA(ERR,
> -			"Failed to allocate memory for mbuf.\n");
> -		return NULL;
> -	}
> -
> -	if (virtio_dev_pktmbuf_prep(dev, pkt, data_len)) {
> -		/* Data doesn't fit into the buffer and the host supports
> -		 * only linear buffers
> -		 */
> -		rte_pktmbuf_free(pkt);
> -		return NULL;
> -	}
> -
> -	return pkt;
> -}
> -
>  __rte_always_inline
>  static uint16_t
>  virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
> @@ -2725,6 +2699,9 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  	VHOST_LOG_DATA(DEBUG, "(%d) about to dequeue %u buffers\n",
>  			dev->vid, count);
> 
> +	if (rte_pktmbuf_alloc_bulk(mbuf_pool, pkts, count))
> +		return 0;
> +
>  	for (i = 0; i < count; i++) {
>  		struct buf_vector buf_vec[BUF_VECTOR_MAX];
>  		uint16_t head_idx;
> @@ -2741,8 +2718,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
> 
>  		update_shadow_used_ring_split(vq, head_idx, 0);
> 
> -		pkts[i] = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len);
> -		if (unlikely(pkts[i] == NULL)) {
> +		err = virtio_dev_pktmbuf_prep(dev, pkts[i], buf_len);
> +		if (unlikely(err)) {
>  			/*
>  			 * mbuf allocation fails for jumbo packets when external
>  			 * buffer allocation is not allowed and linear buffer

I think above comment should be updated too as now mbuf allocation is moved to
another place.

Thanks,
Chenbo

> @@ -2762,7 +2739,6 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  		err = copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, pkts[i],
>  				mbuf_pool, legacy_ol_flags);
>  		if (unlikely(err)) {
> -			rte_pktmbuf_free(pkts[i]);
>  			if (!allocerr_warned) {
>  				VHOST_LOG_DATA(ERR,
>  					"Failed to copy desc to mbuf on %s.\n",
> @@ -2775,6 +2751,9 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  		}
>  	}
> 
> +	if (dropped)
> +		rte_pktmbuf_free_bulk(&pkts[i - 1], count - i + 1);
> +
>  	vq->last_avail_idx += i;
> 
>  	do_data_copy_dequeue(vq);
> --
> 2.31.1


  reply	other threads:[~2021-06-08  6:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 10:26 [dpdk-dev] [PATCH] " Balazs Nemeth
2021-06-04 11:48 ` Maxime Coquelin
2021-06-04 12:14 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
2021-06-08  6:05   ` Xia, Chenbo [this message]
2021-06-08 11:37   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
2021-06-08 11:41     ` [dpdk-dev] [PATCH v4] " Balazs Nemeth
2021-06-17 16:48       ` Maxime Coquelin

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=MN2PR11MB40633D8B6E0F78DFD1064A019C379@MN2PR11MB4063.namprd11.prod.outlook.com \
    --to=chenbo.xia@intel.com \
    --cc=bnemeth@redhat.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.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).