DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] vhost: read last used index once
@ 2021-04-07  9:51 Balazs Nemeth
  2021-04-07  9:55 ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
  0 siblings, 1 reply; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-07  9:51 UTC (permalink / raw)
  To: bnemeth, dev

Instead of calculating the address of a packed descriptor based on the
vq->desc_packed and vq->last_used_idx every time, store that base
address in desc_base. On arm, this saves 176 bytes in code size of
function in which vhost_flush_enqueue_batch_packed gets inlined.

Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
---
 lib/librte_vhost/virtio_net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 179c57b46..f091384a6 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -217,6 +217,8 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
 {
 	uint16_t i;
 	uint16_t flags;
+	uint16_t last_used_idx = vq->last_used_idx;
+	struct vring_packed_desc *desc_base = &vq->desc_packed[last_used_idx];
 
 	if (vq->shadow_used_idx) {
 		do_data_copy_enqueue(dev, vq);
@@ -226,16 +228,17 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
 	flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter);
 
 	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
-		vq->desc_packed[vq->last_used_idx + i].id = ids[i];
-		vq->desc_packed[vq->last_used_idx + i].len = lens[i];
+		desc_base[i].id = ids[i];
+		desc_base[i].len = lens[i];
 	}
 
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 
-	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
-		vq->desc_packed[vq->last_used_idx + i].flags = flags;
+	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
+		desc_base[i].flags = flags;
+	}
 
-	vhost_log_cache_used_vring(dev, vq, vq->last_used_idx *
+	vhost_log_cache_used_vring(dev, vq, last_used_idx *
 				   sizeof(struct vring_packed_desc),
 				   sizeof(struct vring_packed_desc) *
 				   PACKED_BATCH_SIZE);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v3] vhost: read last used index once
  2021-04-07  9:51 [dpdk-dev] [PATCH v2] vhost: read last used index once Balazs Nemeth
@ 2021-04-07  9:55 ` Balazs Nemeth
  2021-04-13 11:42   ` Maxime Coquelin
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-07  9:55 UTC (permalink / raw)
  To: bnemeth, dev

Instead of calculating the address of a packed descriptor based on the
vq->desc_packed and vq->last_used_idx every time, store that base
address in desc_base. On arm, this saves 176 bytes in code size of
function in which vhost_flush_enqueue_batch_packed gets inlined.

Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
---
 lib/librte_vhost/virtio_net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 179c57b46..f091384a6 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -217,6 +217,8 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
 {
 	uint16_t i;
 	uint16_t flags;
+	uint16_t last_used_idx = vq->last_used_idx;
+	struct vring_packed_desc *desc_base = &vq->desc_packed[last_used_idx];
 
 	if (vq->shadow_used_idx) {
 		do_data_copy_enqueue(dev, vq);
@@ -226,16 +228,17 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
 	flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter);
 
 	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
-		vq->desc_packed[vq->last_used_idx + i].id = ids[i];
-		vq->desc_packed[vq->last_used_idx + i].len = lens[i];
+		desc_base[i].id = ids[i];
+		desc_base[i].len = lens[i];
 	}
 
 	rte_atomic_thread_fence(__ATOMIC_RELEASE);
 
-	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
-		vq->desc_packed[vq->last_used_idx + i].flags = flags;
+	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
+		desc_base[i].flags = flags;
+	}
 
-	vhost_log_cache_used_vring(dev, vq, vq->last_used_idx *
+	vhost_log_cache_used_vring(dev, vq, last_used_idx *
 				   sizeof(struct vring_packed_desc),
 				   sizeof(struct vring_packed_desc) *
 				   PACKED_BATCH_SIZE);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: read last used index once
  2021-04-07  9:55 ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
@ 2021-04-13 11:42   ` Maxime Coquelin
  2021-04-28  3:13   ` Xia, Chenbo
  2021-05-08  8:43   ` Ling, WeiX
  2 siblings, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2021-04-13 11:42 UTC (permalink / raw)
  To: Balazs Nemeth, dev



On 4/7/21 11:55 AM, Balazs Nemeth wrote:
> Instead of calculating the address of a packed descriptor based on the
> vq->desc_packed and vq->last_used_idx every time, store that base
> address in desc_base. On arm, this saves 176 bytes in code size of
> function in which vhost_flush_enqueue_batch_packed gets inlined.
> 
> Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
> ---
>  lib/librte_vhost/virtio_net.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 179c57b46..f091384a6 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -217,6 +217,8 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
>  {
>  	uint16_t i;
>  	uint16_t flags;
> +	uint16_t last_used_idx = vq->last_used_idx;
> +	struct vring_packed_desc *desc_base = &vq->desc_packed[last_used_idx];
>  
>  	if (vq->shadow_used_idx) {
>  		do_data_copy_enqueue(dev, vq);
> @@ -226,16 +228,17 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev,
>  	flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter);
>  
>  	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> -		vq->desc_packed[vq->last_used_idx + i].id = ids[i];
> -		vq->desc_packed[vq->last_used_idx + i].len = lens[i];
> +		desc_base[i].id = ids[i];
> +		desc_base[i].len = lens[i];
>  	}
>  
>  	rte_atomic_thread_fence(__ATOMIC_RELEASE);
>  
> -	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
> -		vq->desc_packed[vq->last_used_idx + i].flags = flags;
> +	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> +		desc_base[i].flags = flags;
> +	}
>  
> -	vhost_log_cache_used_vring(dev, vq, vq->last_used_idx *
> +	vhost_log_cache_used_vring(dev, vq, last_used_idx *
>  				   sizeof(struct vring_packed_desc),
>  				   sizeof(struct vring_packed_desc) *
>  				   PACKED_BATCH_SIZE);
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: read last used index once
  2021-04-07  9:55 ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
  2021-04-13 11:42   ` Maxime Coquelin
@ 2021-04-28  3:13   ` Xia, Chenbo
  2021-05-08  8:43   ` Ling, WeiX
  2 siblings, 0 replies; 6+ messages in thread
From: Xia, Chenbo @ 2021-04-28  3:13 UTC (permalink / raw)
  To: Balazs Nemeth, dev

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Balazs Nemeth
> Sent: Wednesday, April 7, 2021 5:55 PM
> To: bnemeth@redhat.com; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3] vhost: read last used index once
> 
> Instead of calculating the address of a packed descriptor based on the
> vq->desc_packed and vq->last_used_idx every time, store that base
> address in desc_base. On arm, this saves 176 bytes in code size of
> function in which vhost_flush_enqueue_batch_packed gets inlined.
> 
> Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
> ---
>  lib/librte_vhost/virtio_net.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 179c57b46..f091384a6 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> --
> 2.30.2

Patch applied to next-virtio/main, thanks


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: read last used index once
  2021-04-07  9:55 ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
  2021-04-13 11:42   ` Maxime Coquelin
  2021-04-28  3:13   ` Xia, Chenbo
@ 2021-05-08  8:43   ` Ling, WeiX
  2021-05-10  7:08     ` Balazs Nemeth
  2 siblings, 1 reply; 6+ messages in thread
From: Ling, WeiX @ 2021-05-08  8:43 UTC (permalink / raw)
  To: Balazs Nemeth, dev

Hi  Balazs Nemeth,

Your patch cause a bug about virtio-user can't recieve packets when use packed ring and ring size is 255.

Please have a look about it.

https://bugs.dpdk.org/show_bug.cgi?id=699

Thanks.

Regards,
Ling Wei

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Balazs Nemeth
> Sent: Wednesday, April 7, 2021 05:55 PM
> To: bnemeth@redhat.com; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3] vhost: read last used index once
> 
> Instead of calculating the address of a packed descriptor based on the
> vq->desc_packed and vq->last_used_idx every time, store that base
> address in desc_base. On arm, this saves 176 bytes in code size of function in
> which vhost_flush_enqueue_batch_packed gets inlined.
> 
> Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
> ---
>  lib/librte_vhost/virtio_net.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index
> 179c57b46..f091384a6 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -217,6 +217,8 @@ vhost_flush_enqueue_batch_packed(struct
> virtio_net *dev,  {
>  	uint16_t i;
>  	uint16_t flags;
> +	uint16_t last_used_idx = vq->last_used_idx;
> +	struct vring_packed_desc *desc_base = &vq-
> >desc_packed[last_used_idx];
> 
>  	if (vq->shadow_used_idx) {
>  		do_data_copy_enqueue(dev, vq);
> @@ -226,16 +228,17 @@ vhost_flush_enqueue_batch_packed(struct
> virtio_net *dev,
>  	flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq-
> >used_wrap_counter);
> 
>  	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> -		vq->desc_packed[vq->last_used_idx + i].id = ids[i];
> -		vq->desc_packed[vq->last_used_idx + i].len = lens[i];
> +		desc_base[i].id = ids[i];
> +		desc_base[i].len = lens[i];
>  	}
> 
>  	rte_atomic_thread_fence(__ATOMIC_RELEASE);
> 
> -	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
> -		vq->desc_packed[vq->last_used_idx + i].flags = flags;
> +	vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> +		desc_base[i].flags = flags;
> +	}
> 
> -	vhost_log_cache_used_vring(dev, vq, vq->last_used_idx *
> +	vhost_log_cache_used_vring(dev, vq, last_used_idx *
>  				   sizeof(struct vring_packed_desc),
>  				   sizeof(struct vring_packed_desc) *
>  				   PACKED_BATCH_SIZE);
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: read last used index once
  2021-05-08  8:43   ` Ling, WeiX
@ 2021-05-10  7:08     ` Balazs Nemeth
  0 siblings, 0 replies; 6+ messages in thread
From: Balazs Nemeth @ 2021-05-10  7:08 UTC (permalink / raw)
  To: Ling, WeiX; +Cc: dev

Hi Ling,

I will take a look. Thanks for reporting.

Regards,
Balazs

On Sat, May 8, 2021 at 10:44 AM Ling, WeiX <weix.ling@intel.com> wrote:

> Hi  Balazs Nemeth,
>
> Your patch cause a bug about virtio-user can't recieve packets when use
> packed ring and ring size is 255.
>
> Please have a look about it.
>
> https://bugs.dpdk.org/show_bug.cgi?id=699
>
> Thanks.
>
> Regards,
> Ling Wei
>
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Balazs Nemeth
> > Sent: Wednesday, April 7, 2021 05:55 PM
> > To: bnemeth@redhat.com; dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH v3] vhost: read last used index once
> >
> > Instead of calculating the address of a packed descriptor based on the
> > vq->desc_packed and vq->last_used_idx every time, store that base
> > address in desc_base. On arm, this saves 176 bytes in code size of
> function in
> > which vhost_flush_enqueue_batch_packed gets inlined.
> >
> > Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
> > ---
> >  lib/librte_vhost/virtio_net.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/librte_vhost/virtio_net.c
> b/lib/librte_vhost/virtio_net.c index
> > 179c57b46..f091384a6 100644
> > --- a/lib/librte_vhost/virtio_net.c
> > +++ b/lib/librte_vhost/virtio_net.c
> > @@ -217,6 +217,8 @@ vhost_flush_enqueue_batch_packed(struct
> > virtio_net *dev,  {
> >       uint16_t i;
> >       uint16_t flags;
> > +     uint16_t last_used_idx = vq->last_used_idx;
> > +     struct vring_packed_desc *desc_base = &vq-
> > >desc_packed[last_used_idx];
> >
> >       if (vq->shadow_used_idx) {
> >               do_data_copy_enqueue(dev, vq);
> > @@ -226,16 +228,17 @@ vhost_flush_enqueue_batch_packed(struct
> > virtio_net *dev,
> >       flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq-
> > >used_wrap_counter);
> >
> >       vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> > -             vq->desc_packed[vq->last_used_idx + i].id = ids[i];
> > -             vq->desc_packed[vq->last_used_idx + i].len = lens[i];
> > +             desc_base[i].id = ids[i];
> > +             desc_base[i].len = lens[i];
> >       }
> >
> >       rte_atomic_thread_fence(__ATOMIC_RELEASE);
> >
> > -     vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
> > -             vq->desc_packed[vq->last_used_idx + i].flags = flags;
> > +     vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
> > +             desc_base[i].flags = flags;
> > +     }
> >
> > -     vhost_log_cache_used_vring(dev, vq, vq->last_used_idx *
> > +     vhost_log_cache_used_vring(dev, vq, last_used_idx *
> >                                  sizeof(struct vring_packed_desc),
> >                                  sizeof(struct vring_packed_desc) *
> >                                  PACKED_BATCH_SIZE);
> > --
> > 2.30.2
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-10  7:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07  9:51 [dpdk-dev] [PATCH v2] vhost: read last used index once Balazs Nemeth
2021-04-07  9:55 ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
2021-04-13 11:42   ` Maxime Coquelin
2021-04-28  3:13   ` Xia, Chenbo
2021-05-08  8:43   ` Ling, WeiX
2021-05-10  7:08     ` Balazs Nemeth

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).