Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753339AbbBZGUG (ORCPT ); Thu, 26 Feb 2015 01:20:06 -0500 Received: from linuxhacker.ru ([217.76.32.60]:53672 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751340AbbBZGUD (ORCPT ); Thu, 26 Feb 2015 01:20:03 -0500 From: green@linuxhacker.ru To: Rusty Russell , Andrew Morton , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Oleg Drokin Subject: [PATCH 2/2] cpumask: make whole cpumask operations like copy to work with NR_CPUS bits Date: Thu, 26 Feb 2015 01:19:11 -0500 Message-Id: <1424931551-11757-3-git-send-email-green@linuxhacker.ru> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1424931551-11757-1-git-send-email-green@linuxhacker.ru> References: <1424931551-11757-1-git-send-email-green@linuxhacker.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2487 Lines: 73 From: Oleg Drokin When we are doing things like cpumask_copy, and CONFIG_CPUMASK_OFFSTACK is set, we only copy actual number of bits equal to number of CPUs we have. But underlying allocations got NR_CPUS = 8192, so if the cpumask is allocated on the stack or has other prefilled values there's a lot of garbage left that might become exposed as more CPUs are added into the system. The patch converts such whole-mask functions: cpumask_setall, cpumask_clear, cpumask_copy to operate on the whole NR_CPUS value. Signed-off-by: Oleg Drokin --- include/linux/cpumask.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index f0599e1..28a8bb3 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -324,21 +324,21 @@ static inline int cpumask_test_and_clear_cpu(int cpu, struct cpumask *cpumask) } /** - * cpumask_setall - set all cpus (< nr_cpu_ids) in a cpumask + * cpumask_setall - set all cpus (< NR_CPUS) in a cpumask * @dstp: the cpumask pointer */ static inline void cpumask_setall(struct cpumask *dstp) { - bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits); + bitmap_fill(cpumask_bits(dstp), NR_CPUS); } /** - * cpumask_clear - clear all cpus (< nr_cpu_ids) in a cpumask + * cpumask_clear - clear all cpus (< NR_CPUS) in a cpumask * @dstp: the cpumask pointer */ static inline void cpumask_clear(struct cpumask *dstp) { - bitmap_zero(cpumask_bits(dstp), nr_cpumask_bits); + bitmap_zero(cpumask_bits(dstp), NR_CPUS); } /** @@ -470,7 +470,7 @@ static inline bool cpumask_full(const struct cpumask *srcp) /** * cpumask_weight - Count of bits in *srcp - * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @srcp: the cpumask to count bits (< NR_CPUS) in. */ static inline unsigned int cpumask_weight(const struct cpumask *srcp) { @@ -511,7 +511,7 @@ static inline void cpumask_shift_left(struct cpumask *dstp, static inline void cpumask_copy(struct cpumask *dstp, const struct cpumask *srcp) { - bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits); + bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), NR_CPUS); } /** -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/