On 3/18/21 4:23 AM, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coque...@redhat.com>
>> Sent: Thursday, March 18, 2021 1:09 AM
>> To: dev@dpdk.org; Xia, Chenbo <chenbo....@intel.com>; amore...@redhat.com;
>> david.march...@redhat.com; olivier.m...@6wind.com; bnem...@redhat.com
>> Cc: Maxime Coquelin <maxime.coque...@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.coque...@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
> 

Reply via email to