From: Yonglong Liu <liuyonglong@xxxxxxxxxx> 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 <liuyonglong@xxxxxxxxxx> Signed-off-by: Jijie Shao <shaojijie@xxxxxxxxxx> --- 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