Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp921556rwb; Fri, 28 Jul 2023 01:43:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlHz0ns6ZbLsNQK4vlX5+KJDWQgqQaKxqeT9bxgpe0ROzoa8wDIMyWUL0FZLIuWcMqtBPdiJ X-Received: by 2002:a17:906:8a74:b0:99b:cf4f:9090 with SMTP id hy20-20020a1709068a7400b0099bcf4f9090mr1359728ejc.66.1690533824772; Fri, 28 Jul 2023 01:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690533824; cv=none; d=google.com; s=arc-20160816; b=NIpetK95zRqGPRMJrDoYaYok1uufKjXau+LVku0VKwLGEOP0rmHC6dQSLWzqdZ0tKW 7nU97xy7pBkNC3a7OEcjmZY1ELhclctSgAUkvHEIizRen+3KTR4/6FqI0FetwzFT0EBw 8Uvt/zhJjtJKB+cv53gEnaMNrLq5ofTqZZKXkureS5OvXARYhnhGx4M2zPwMNKjo3t6N DS2u3SEWBUohVe5U4WSZ4bkH171iEpyxQdCeROA6nsJhLOYo+XgPEG48nP29etDLrky3 sf85HIl5YLnrVRqUuami9h3SuL9ArQMKdzDc17pmQ3RKKqsKNLvWEyifs5kRrFf2//xH EahA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lLDbmCEaAZO40s04jFYODKf8rnCCRz264W4q+WqEhdg=; fh=rhoMx0VN1EBFBgM+MRLh5DDELNHeiDru4nB1GuImL/0=; b=m/22h7erZK+v/d0QsKFanQsEqc0UJYlV73MR8nxD7MhyXL5KcSSiTvV9AEagamvIoC UZcfgphu3Y2y3SF6J2qjUkFagce1sNkJlwHqP/Ov2++X3KUeSvzOAKpjfCAiOY9y7Zzh SCHNwPQ/vNw5M26iuRc1f1yk2DXkObqDXBNbxquhnRimcDB+yu7k8ff4XS+cnznyNrzB 1PZlNQ1HKrNDmr1JA6s4vLWoIz1cFNtKw8W7QYp75JBB5RdVYEodDkSZsfb4buwi1bQN bT/TwCFExoH5Ay9OSYUNJHPjh0IjLhBtNUzPTTLNHQ/00KULV7KcT91Qpx9uED6Cl4Bu Qc1Q== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u25-20020a170906069900b0099307a5a755si2308664ejb.45.2023.07.28.01.43.20; Fri, 28 Jul 2023 01:43:44 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234735AbjG1IEZ (ORCPT + 99 others); Fri, 28 Jul 2023 04:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234620AbjG1IDv (ORCPT ); Fri, 28 Jul 2023 04:03:51 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B638B3C01; Fri, 28 Jul 2023 01:01:51 -0700 (PDT) Received: from kwepemm600007.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RC0PY1gKpzNmbb; Fri, 28 Jul 2023 15:58:25 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 16:01:48 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , Subject: [PATCH net 1/6] net: hns3: fix side effects passed to min_t() Date: Fri, 28 Jul 2023 15:58:35 +0800 Message-ID: <20230728075840.4022760-2-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230728075840.4022760-1-shaojijie@huawei.com> References: <20230728075840.4022760-1-shaojijie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 From: Yonglong Liu num_online_cpus() may call more than once when passing to min_t(), between calls, it may return different values, so move num_online_cpus() out of min_t(). Signed-off-by: Yonglong Liu Signed-off-by: Jijie Shao --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 9f6890059666..823e6d2e85f5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4757,6 +4757,7 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) { struct hnae3_handle *h = priv->ae_handle; struct hns3_enet_tqp_vector *tqp_vector; + u32 online_cpus = num_online_cpus(); struct hnae3_vector_info *vector; struct pci_dev *pdev = h->pdev; u16 tqp_num = h->kinfo.num_tqps; @@ -4766,7 +4767,7 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv) /* RSS size, cpu online and vector_num should be the same */ /* Should consider 2p/4p later */ - vector_num = min_t(u16, num_online_cpus(), tqp_num); + vector_num = min_t(u16, online_cpus, tqp_num); vector = devm_kcalloc(&pdev->dev, vector_num, sizeof(*vector), GFP_KERNEL); -- 2.30.0