Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1542125pxb; Thu, 28 Oct 2021 05:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZhJsSEH8yhMfUO6aoUplktnmpf9RV9LwPGbwSrwc1nOHMCLjXIf0WfjIIhPYXAxTbATxs X-Received: by 2002:a17:907:2854:: with SMTP id el20mr5285399ejc.416.1635425241495; Thu, 28 Oct 2021 05:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635425241; cv=none; d=google.com; s=arc-20160816; b=JoIiPTYaMqAMM+6SWICLHElxAbPOKmMvsbxdW+nIeuB07ohD+RYIhvfUNQJ+0AzuYr r/5/3lj+s8sXy6ufTi5cJq8MLrBftlmp+kRtZUl1q/wqNNTEmxuwg+RfgTFfty0QH6i2 hPh8eiAAD2TjzaH+f9dilOkYy6ZkcXv+4O2SwY4dKnGWPDrpTC0l7YyGHWLF7gSbrayx ut5cj9bhttfo9b1ryCSQihiEZeqKCaj6ENsUWoCmZJyYtvedFYiqlaPFVmGTO43DAv7E LcQr5LHGBb1OMQbwOxhAhY1ujCm97eLQ9omr8IN2yaY4UKr40RhKyq9j9tefA8qpjLPp aXjg== 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=tbjYmVRwqh9L7vauw8ttApZ2Vop4uQnEVZJr6dihsnI=; b=iDUY2yZNKVUa6mGZrRJW1Ha2xtUSMzBdic+u6nE5fbnSswQ3EjkmD9bYUHW0sC6HVg HiMeTw5DrjhNy82fP/Z1U+BD8IL9JitkP6BFCvjFAiZAe1bIPIPXNYCmdilW/8I99CRs IoBl+UfrPt+MC6WB0zP/TZE3NgQW4CdWe8ygYlu7Z3u46Ico3ZfJ+Sr8/EWMJeNJHtyA dtYztxnMoqdFgkLqnB1UKszaE03W7v5/H4ZQJq7YVObt4fJga9K+IQdGdfFKzbhCJBbI ZL+U1gnZ2qTW62JWXlkhaAdIhVfmM3/9G96+WwfGoQxpDHz/gMwJXRVWn8IQp1IdVqi7 gHXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hu16si3532346ejc.642.2021.10.28.05.46.39; Thu, 28 Oct 2021 05:47:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbhJ1Mok (ORCPT + 99 others); Thu, 28 Oct 2021 08:44:40 -0400 Received: from smtp25.cstnet.cn ([159.226.251.25]:53434 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229578AbhJ1Mok (ORCPT ); Thu, 28 Oct 2021 08:44:40 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-05 (Coremail) with SMTP id zQCowADHifaMmnphjOSBBQ--.18442S2; Thu, 28 Oct 2021 20:41:48 +0800 (CST) From: Jiasheng Jiang To: peterz@infradead.org, valentin.schneider@arm.com, namit@vmware.com, mingo@kernel.org, dave.hansen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH v4] cpumask: Fix implicit type conversion Date: Thu, 28 Oct 2021 12:41:47 +0000 Message-Id: <1635424907-1686047-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: zQCowADHifaMmnphjOSBBQ--.18442S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw45JrW5CFyrKFWDAr48Crg_yoW8KFyUpr yvgrWUKr48ArWkX34UAayUCw1F9397J39Fk34UGF1UurW3Jw18ZrnF9F9Iqr17CFykGrya 9r929rWY9F1rAFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_Xr1l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUDWrXUUUUU= X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although the upper bounds for NR_CPUS are less than 2^13 now, maybe in the future the NR_CPUS will increase and become bigger than INT_MAX. Therefore, it might be better to add the assertion in case it will be forgotten when the futurn come true. Anyway, patch costs much less than the loss. Also, it might be better to fix the macro description of 'cpu' and deal with all the existing issues. Signed-off-by: Jiasheng Jiang --- include/linux/cpumask.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index bfc4690..c433c9b 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -183,7 +183,7 @@ static inline int cpumask_any_distribute(const struct cpumask *srcp) for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)(start)) #define for_each_cpu_and(cpu, mask1, mask2) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask1, (void)mask2) -#else +#elif NR_CPUS <= 2147483647 /** * cpumask_first - get the first cpu in a cpumask * @srcp: the cpumask pointer @@ -232,7 +232,7 @@ int cpumask_any_distribute(const struct cpumask *srcp); /** * for_each_cpu - iterate over every cpu in a mask - * @cpu: the (optionally unsigned) integer iterator + * @cpu: the integer iterator * @mask: the cpumask pointer * * After the loop, cpu is >= nr_cpu_ids. @@ -244,7 +244,7 @@ int cpumask_any_distribute(const struct cpumask *srcp); /** * for_each_cpu_not - iterate over every cpu in a complemented mask - * @cpu: the (optionally unsigned) integer iterator + * @cpu: the integer iterator * @mask: the cpumask pointer * * After the loop, cpu is >= nr_cpu_ids. @@ -258,7 +258,7 @@ extern int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool /** * for_each_cpu_wrap - iterate over every cpu in a mask, starting at a specified location - * @cpu: the (optionally unsigned) integer iterator + * @cpu: the integer iterator * @mask: the cpumask poiter * @start: the start location * @@ -273,7 +273,7 @@ extern int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool /** * for_each_cpu_and - iterate over every cpu in both masks - * @cpu: the (optionally unsigned) integer iterator + * @cpu: the integer iterator * @mask1: the first cpumask pointer * @mask2: the second cpumask pointer * -- 2.7.4