From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"amorenoz@redhat.com" <amorenoz@redhat.com>,
"david.marchand@redhat.com" <david.marchand@redhat.com>,
"olivier.matz@6wind.com" <olivier.matz@6wind.com>,
"bnemeth@redhat.com" <bnemeth@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v3 3/3] vhost: optimize vhost virtqueue struct
Date: Tue, 23 Mar 2021 09:51:59 +0100 [thread overview]
Message-ID: <28a007ba-e60a-8a26-3279-2791dd73f322@redhat.com> (raw)
In-Reply-To: <MN2PR11MB4063EE3BE102CD6C076BE76B9C699@MN2PR11MB4063.namprd11.prod.outlook.com>
On 3/18/21 4:23 AM, Xia, Chenbo wrote:
> Hi Maxime,
>
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Thursday, March 18, 2021 1:09 AM
>> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; amorenoz@redhat.com;
>> david.marchand@redhat.com; olivier.matz@6wind.com; bnemeth@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [PATCH v3 3/3] vhost: optimize vhost virtqueue struct
>>
>> This patch moves vhost_virtqueue struct fields in order
>> to both optimize packing and move hot fields on the first
>> cachelines.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>> lib/librte_vhost/vhost.c | 6 ++--
>> lib/librte_vhost/vhost.h | 54 ++++++++++++++++++-----------------
>> lib/librte_vhost/vhost_user.c | 19 ++++++------
>> lib/librte_vhost/virtio_net.c | 12 ++++----
>> 4 files changed, 46 insertions(+), 45 deletions(-)
>>
>> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
>> index a8032e3ba1..04d63b2f02 100644
>> --- a/lib/librte_vhost/vhost.c
>> +++ b/lib/librte_vhost/vhost.c
>> @@ -524,7 +524,7 @@ vring_translate(struct virtio_net *dev, struct
>> vhost_virtqueue *vq)
>> if (log_translate(dev, vq) < 0)
>> return -1;
>>
>> - vq->access_ok = 1;
>> + vq->access_ok = true;
>>
>> return 0;
>> }
>> @@ -535,7 +535,7 @@ vring_invalidate(struct virtio_net *dev, struct
>> vhost_virtqueue *vq)
>> if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
>> vhost_user_iotlb_wr_lock(vq);
>>
>> - vq->access_ok = 0;
>> + vq->access_ok = false;
>> vq->desc = NULL;
>> vq->avail = NULL;
>> vq->used = NULL;
>> @@ -1451,7 +1451,7 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)
>>
>> rte_spinlock_lock(&vq->access_lock);
>>
>> - if (unlikely(vq->enabled == 0 || vq->avail == NULL))
>> + if (unlikely(!vq->enabled || vq->avail == NULL))
>> goto out;
>>
>> ret = *((volatile uint16_t *)&vq->avail->idx) - vq->last_avail_idx;
>> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
>> index 3a71dfeed9..f628714c24 100644
>> --- a/lib/librte_vhost/vhost.h
>> +++ b/lib/librte_vhost/vhost.h
>> @@ -133,7 +133,7 @@ struct vhost_virtqueue {
>> struct vring_used *used;
>> struct vring_packed_desc_event *device_event;
>> };
>> - uint32_t size;
>> + uint16_t size;
>>
>> uint16_t last_avail_idx;
>> uint16_t last_used_idx;
>> @@ -143,29 +143,12 @@ struct vhost_virtqueue {
>> #define VIRTIO_INVALID_EVENTFD (-1)
>> #define VIRTIO_UNINITIALIZED_EVENTFD (-2)
>>
>> - int enabled;
>> - int access_ok;
>> - int ready;
>> - int notif_enable;
>> -#define VIRTIO_UNINITIALIZED_NOTIF (-1)
>> + bool enabled;
>> + bool access_ok;
>> + bool ready;
> In vhost_user_set_vring_call and vhost_user_set_vring_kick, 'vq->ready = 0' should
> also be changed to 'vq->ready = false' 😊.
Thanks Chenbo, I indeed missed these. V4 is on its way.
Maxime
> Thanks,
> Chenbo
>
prev parent reply other threads:[~2021-03-23 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 17:09 [dpdk-dev] [PATCH v3 0/3] vhost: make virtqueue cache-friendly Maxime Coquelin
2021-03-17 17:09 ` [dpdk-dev] [PATCH v3 1/3] vhost: remove unused Vhost virtqueue field Maxime Coquelin
2021-03-17 17:09 ` [dpdk-dev] [PATCH v3 2/3] vhost: move dirty logging cache out of the virtqueue Maxime Coquelin
2021-03-18 3:24 ` Xia, Chenbo
2021-03-17 17:09 ` [dpdk-dev] [PATCH v3 3/3] vhost: optimize vhost virtqueue struct Maxime Coquelin
2021-03-18 3:23 ` Xia, Chenbo
2021-03-23 8:51 ` Maxime Coquelin [this message]
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=28a007ba-e60a-8a26-3279-2791dd73f322@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=amorenoz@redhat.com \
--cc=bnemeth@redhat.com \
--cc=chenbo.xia@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.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).