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 81518A0524; Tue, 13 Apr 2021 13:42:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12151160E6D; Tue, 13 Apr 2021 13:42:13 +0200 (CEST) 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 5670B1606E1 for ; Tue, 13 Apr 2021 13:42:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618314131; 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=zZc53IsxroH/EVNh0/V4itDAmkqdxnNqy2UpLmepPws=; b=PRiQsmhDyhumUYfPeaptzjTrttKMmzNotxKhVZP3FNcZCulze8YeBGYlqJpZi+P6uOET/+ wQhLw3y/42NDhrHqZ5udf3tLImpfGspcybIXHYzziJFQdiJ3DqwOTkMsQH1ScM5DDykNAm UxPG+Rj29SoO2f3sNoN7QRh6kQY2Rgs= 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-238-TcER7BMQNxqgEJlC0n6Eww-1; Tue, 13 Apr 2021 07:42:10 -0400 X-MC-Unique: TcER7BMQNxqgEJlC0n6Eww-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1741107ACCA for ; Tue, 13 Apr 2021 11:42:09 +0000 (UTC) Received: from [10.36.110.28] (unknown [10.36.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 091F65D9DE; Tue, 13 Apr 2021 11:42:08 +0000 (UTC) To: Balazs Nemeth , dev@dpdk.org References: <8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789063.git.bnemeth@redhat.com> <8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789236.git.bnemeth@redhat.com> From: Maxime Coquelin Message-ID: <2c3bd046-19d2-3291-6451-3d5144ba12c3@redhat.com> Date: Tue, 13 Apr 2021 13:42:07 +0200 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: <8b9b42cf2b18feb41c4b64a174ccc154847c59f9.1617789236.git.bnemeth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 7bit Subject: Re: [dpdk-dev] [PATCH v3] vhost: read last used index once 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 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 > --- > 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 Thanks, Maxime