From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B744A0562; Tue, 23 Mar 2021 09:52:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 138974014D; Tue, 23 Mar 2021 09:52:16 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 403D240143 for ; Tue, 23 Mar 2021 09:52:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616489534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JIIaJIZUTcdPfxdHkBxiczpNp13ybpCxrip2BWho/Ic=; b=grZIVa/oQh9yRxLLdvh53Vy66/BTesee+792W0USnALhakMVRLplKZ+DIY41c0O969Ip8K RH3RVaeFKEv/JK6DULDvixgsOZodb7NWtjFORqOnzLhu+udLC8w7H6icv75xpdSLEnDeSs gpA1tlLKCTBc30gLdPNu2mdyvOqZH8w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-116-0LuirIajO5WqJFx7tq5nkQ-1; Tue, 23 Mar 2021 04:52:10 -0400 X-MC-Unique: 0LuirIajO5WqJFx7tq5nkQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 985B3180FCAA; Tue, 23 Mar 2021 08:52:09 +0000 (UTC) Received: from [10.36.110.41] (unknown [10.36.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AA8B1F453; Tue, 23 Mar 2021 08:52:01 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "amorenoz@redhat.com" , "david.marchand@redhat.com" , "olivier.matz@6wind.com" , "bnemeth@redhat.com" References: <20210317170922.25046-1-maxime.coquelin@redhat.com> <20210317170922.25046-4-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <28a007ba-e60a-8a26-3279-2791dd73f322@redhat.com> Date: Tue, 23 Mar 2021 09:51:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v3 3/3] vhost: optimize vhost virtqueue struct X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 3/18/21 4:23 AM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Thursday, March 18, 2021 1:09 AM >> To: dev@dpdk.org; Xia, Chenbo ; amorenoz@redhat.com; >> david.marchand@redhat.com; olivier.matz@6wind.com; bnemeth@redhat.com >> Cc: Maxime Coquelin >> 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 >> --- >> 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 >