Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5589852pxb; Mon, 28 Mar 2022 14:38:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhV/nH8h9RG7aCg791mfv+y/JBRi2SpGYGUGYb4v4L1y7XNwSz33NfmLmu1PhQEyUOcMr4 X-Received: by 2002:a05:6808:1884:b0:2da:3946:ab3e with SMTP id bi4-20020a056808188400b002da3946ab3emr626031oib.223.1648503521274; Mon, 28 Mar 2022 14:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648503521; cv=none; d=google.com; s=arc-20160816; b=Hi0zqYSX/9C5wzNmdmJUrCXumX76Rb+8Gjt1liZsJ61EJJDi12Imrrr4yIZDGlHVQt miausSoYqp0fxiYLQbQvhtESxczD1SWYj+rXdxbC4olEojs6k7G4cGEZawb39iXPTF3o uhvmOItx+CvfC0VZ6SycTfjVra6sJmAJ2WWQdQmdgP1R8jmEi6LpTCnhoQkHP1ve8MPJ 5PUmM+sTFyNfywg1NXPSy+n7kDS9XcrQWIVs08BQcF+o5dFsYZlUfB/b5iC8vmXLh9Yl TSCfP3uVGR4Bj6yVKKt1O8ZnHqooskq64pnWh3uV1rKpVAObpkg+lxFyvO2iVClgOM+q AxFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=R3GT+3F+kzQCYdx8p5Wk3IRGJPQw0nUr9SZOizuaWf4=; b=DsXDC9yOlcHv7wFMtxM4H+TaZ1X//qSeyhSGlNDr05M6OwgLiqHBT3Eqrpoa1G6RBa 1OzaL6FRBSg3DhUdYIf2CVkl06/cgmEL1kDb5yuhqnOfgzmS8ob4x2uN4gOGkwbepJem ujiSgb+PXxi6UZRy3IhN1vRkwOQxFDarpO4J78kdzrGXUOGjiULf5dpkLloephMcAuIf bFoXEMjqNjSVv2XYuBMMwPe9NdkZ0tR4CCUHpv3ondnX5ct2LvsawWqD8WVURWd52yar AGP5uTsmKf51tZtaUpyHOGa7FZr9hFuUcCudwN91ORQdPJlVK5+Pu6tsl/iV51Je2sa+ cFfg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n8-20020a0568301e8800b005cb2fc1386dsi11546673otr.233.2022.03.28.14.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2F5E90FEF; Mon, 28 Mar 2022 14:16:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240436AbiC1LAI (ORCPT + 99 others); Mon, 28 Mar 2022 07:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240430AbiC1LAF (ORCPT ); Mon, 28 Mar 2022 07:00:05 -0400 Received: from out199-15.us.a.mail.aliyun.com (out199-15.us.a.mail.aliyun.com [47.90.199.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58EF11C103 for ; Mon, 28 Mar 2022 03:58:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0V8SAF7z_1648465100; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0V8SAF7z_1648465100) by smtp.aliyun-inc.com(127.0.0.1); Mon, 28 Mar 2022 18:58:20 +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 2/2] virtio_ring: add unlikely annotation for free descs check Date: Mon, 28 Mar 2022 18:58:17 +0800 Message-Id: <20220328105817.1028065-2-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220328105817.1028065-1-xianting.tian@linux.alibaba.com> References: <20220328105817.1028065-1-xianting.tian@linux.alibaba.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 The 'if (vq->vq.num_free < descs_used)' check will almost always be false. Signed-off-by: Xianting Tian --- drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index d597fc0874ec..ab6d5f0cb579 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -525,7 +525,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, descs_used = total_sg; } - if (vq->vq.num_free < descs_used) { + if (unlikely(vq->vq.num_free < descs_used)) { pr_debug("Can't add buf len %i - avail = %i\n", descs_used, vq->vq.num_free); /* FIXME: for historical reasons, we force a notify here if -- 2.17.1