From nobody Thu Apr 9 12:08:21 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58BA0C32771 for ; Mon, 26 Sep 2022 09:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234479AbiIZJLn (ORCPT ); Mon, 26 Sep 2022 05:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234117AbiIZJLk (ORCPT ); Mon, 26 Sep 2022 05:11:40 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C2F3B948 for ; Mon, 26 Sep 2022 02:11:38 -0700 (PDT) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((D)) with ASMTP (SSL) id VKM00133; Mon, 26 Sep 2022 17:11:33 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201612.home.langchao.com (10.100.2.12) with Microsoft SMTP Server id 15.1.2507.12; Mon, 26 Sep 2022 17:11:31 +0800 From: Bo Liu To: , CC: , , Bo Liu Subject: [PATCH] virtio_ring: remove unnecessary to_vvq() call Date: Mon, 26 Sep 2022 05:11:30 -0400 Message-ID: <20220926091130.9244-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.200.104.97] tUid: 2022926171133d6dd2f1451e4b2b3042fc445a84fcdfb X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It passes '_vq' to vring_free(), which still calls to_vvq() to get 'vq', let's directly pass 'vq'. It can avoid unnecessary call of to_vvq() in hot path. Signed-off-by: Bo Liu Acked-by: Jason Wang --- drivers/virtio/virtio_ring.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 8974c34b40fd..d6d77bf58802 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -221,7 +221,7 @@ static struct virtqueue *__vring_new_virtqueue(unsigned= int index, void (*callback)(struct virtqueue *), const char *name); static struct vring_desc_extra *vring_alloc_desc_extra(unsigned int num); -static void vring_free(struct virtqueue *_vq); +static void vring_free(struct vring_virtqueue *vq); =20 /* * Helpers. @@ -1140,7 +1140,7 @@ static int virtqueue_resize_split(struct virtqueue *_= vq, u32 num) if (err) goto err_state_extra; =20 - vring_free(&vq->vq); + vring_free(vq); =20 virtqueue_vring_init_split(&vring_split, vq); =20 @@ -2059,7 +2059,7 @@ static int virtqueue_resize_packed(struct virtqueue *= _vq, u32 num) if (err) goto err_state_extra; =20 - vring_free(&vq->vq); + vring_free(vq); =20 virtqueue_vring_init_packed(&vring_packed, !!vq->vq.callback); =20 @@ -2649,10 +2649,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int i= ndex, } EXPORT_SYMBOL_GPL(vring_new_virtqueue); =20 -static void vring_free(struct virtqueue *_vq) +static void vring_free(struct vring_virtqueue *vq) { - struct vring_virtqueue *vq =3D to_vvq(_vq); - if (vq->we_own_ring) { if (vq->packed_ring) { vring_free_queue(vq->vq.vdev, @@ -2693,7 +2691,7 @@ void vring_del_virtqueue(struct virtqueue *_vq) list_del(&_vq->list); spin_unlock(&vq->vq.vdev->vqs_list_lock); =20 - vring_free(_vq); + vring_free(vq); =20 kfree(vq); } --=20 2.27.0