All of lore.kernel.org
 help / color / mirror / Atom feed
From: Balazs Nemeth <bnemeth@redhat.com>
To: bnemeth@redhat.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3] vhost: read last used index once
Date: Wed,  7 Apr 2021 11:55:27 +0200	[thread overview]
Message-ID: <8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789236.git.bnemeth@redhat.com> (raw)
In-Reply-To: <8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789063.git.bnemeth@redhat.com>

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


  reply	other threads:[~2021-04-07  9:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  9:51 [dpdk-dev] [PATCH v2] vhost: read last used index once Balazs Nemeth
2021-04-07  9:55 ` Balazs Nemeth [this message]
2021-04-13 11:42   ` [dpdk-dev] [PATCH v3] " Maxime Coquelin
2021-04-28  3:13   ` Xia, Chenbo
2021-05-08  8:43   ` Ling, WeiX
2021-05-10  7:08     ` Balazs Nemeth

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=8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789236.git.bnemeth@redhat.com \
    --to=bnemeth@redhat.com \
    --cc=dev@dpdk.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.