Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5218543pxb; Mon, 28 Mar 2022 09:32:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyniSdSoWl36CtkFfwr2ex+WjIPsR+unVkUUh9+oSsaABBKrshB5roJ2JMAfn0kPfgksyXK X-Received: by 2002:a63:1c7:0:b0:37c:4e86:25e9 with SMTP id 190-20020a6301c7000000b0037c4e8625e9mr10750133pgb.550.1648485150858; Mon, 28 Mar 2022 09:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648485150; cv=none; d=google.com; s=arc-20160816; b=zEkoPHhgdTamH1FC8IvDDee1rbS13Rsji+VCe658cWGujKy203lfTS5y9Ww+R667Ub o8MRAkSuHXVQ40QINPWDKn4tjiyT5GIaK6oKn+UENyPDgSvi5KfCDQINomVqSt/Jklcm vVLi86sBaw4DC2i7Yn39roTpLnN61V2+JW/IAUe58oLYzx6975sI26Gn5qIH1+vmCpXU MjdaoKQvFYs69NYoIR6FsnnJ2mlfmKalctZtuErshCWFVlB+bboxGKwwUr52+K9nnOog 1uN8bDjHaAaoODsm2QM5i6bqibpijou19xD2Pd+EL4T5hTxzO9U1cZxBwhSR4brhNSnE eaeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=F972dt3BmPTf/k/O+MR/XeBs01IC+bvDvq+NyAOCy8o=; b=QZvYmRD/1M7D2QHiRSALUF3smFANJJK2SCIdBl2bKKa82HPPwZNi++pTgrGCB+ztPJ vLnoyXHE+Mfv/hlO7v21C+BFYHkcBiMLq7+xSeHj4uvT8+Uu6T//3XFSznyydB1t+fOO l3yN0jOFttHtQ5VK6UrgRizwU81GbIQg5MBFkMa4KlCWA638opQRth8k1Ufh74uLVC8i tmMzo3sO3KyCmCICMeVk1w9HrEOMALYOLFDxa1hrGJLfewFy91w0PPecALuIQLwPx/sS eDw5mp20MZfbeE9uLHb4Tg6sF2tUybBAu35683NMBqAhrthlseWimAWk4fqZ/wBae7zI I5VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a056a00214500b004faabba35aesi12921946pfk.289.2022.03.28.09.32.16; Mon, 28 Mar 2022 09:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240424AbiC1LAE (ORCPT + 99 others); Mon, 28 Mar 2022 07:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239700AbiC1LAD (ORCPT ); Mon, 28 Mar 2022 07:00:03 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189D817069 for ; Mon, 28 Mar 2022 03:58:21 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0V8R4is0_1648465099; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0V8R4is0_1648465099) by smtp.aliyun-inc.com(127.0.0.1); Mon, 28 Mar 2022 18:58:19 +0800 From: Xianting Tian To: mst@redhat.com, jasowang@redhat.com, sgarzare@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Xianting Tian Subject: [PATCH 1/2] virtio_ring: remove unnecessary to_vvq call in vring hot path Date: Mon, 28 Mar 2022 18:58:16 +0800 Message-Id: <20220328105817.1028065-1-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It passes '_vq' to virtqueue_use_indirect(), 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: Xianting Tian --- drivers/virtio/virtio_ring.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 962f1477b1fa..d597fc0874ec 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -205,11 +205,9 @@ struct vring_virtqueue { #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) -static inline bool virtqueue_use_indirect(struct virtqueue *_vq, +static inline bool virtqueue_use_indirect(struct vring_virtqueue *vq, unsigned int total_sg) { - struct vring_virtqueue *vq = to_vvq(_vq); - /* * If the host supports indirect descriptor tables, and we have multiple * buffers, then go indirect. FIXME: tune this threshold @@ -507,7 +505,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, head = vq->free_head; - if (virtqueue_use_indirect(_vq, total_sg)) + if (virtqueue_use_indirect(vq, total_sg)) desc = alloc_indirect_split(_vq, total_sg, gfp); else { desc = NULL; @@ -1194,7 +1192,7 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq, BUG_ON(total_sg == 0); - if (virtqueue_use_indirect(_vq, total_sg)) { + if (virtqueue_use_indirect(vq, total_sg)) { err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs, in_sgs, data, gfp); if (err != -ENOMEM) { -- 2.17.1