From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH v2 2/9] x86: numa: check the node id consistently for x86 Date: Mon, 2 Sep 2019 20:17:31 +0200 Message-ID: <20190902181731.GB35858@gmail.com> References: <1567231103-13237-1-git-send-email-linyunsheng@huawei.com> <1567231103-13237-3-git-send-email-linyunsheng@huawei.com> <20190831085539.GG2369@hirez.programming.kicks-ass.net> <4d89c688-49e4-a2aa-32ee-65e36edcd913@huawei.com> <20190831161247.GM2369@hirez.programming.kicks-ass.net> <20190902072542.GN2369@hirez.programming.kicks-ass.net> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jBcP8+814FXVBIRmjcz1VaPKi5ctF20nPKwL6I2CNCQ=; b=faS7HABw9gu83gEWeJ9t0e3z7PXG4M/CTkKuWq9ZyzIl2d/x/mrg8a4P2YSBHuKkSK j2Jg0qR3ZMKYg3+W7fvfsjaTQsvaBLPDjNaHD1ciIoo++3q8Gq3ayEnY4ZosSMskNtna jtIMiT5+IthZl4oiuye8lom+YlFCguCKVcGl1nUVQkkkmDfAOOc02yjm+c6tbI9xlQfY V3XPL6hwvqyqMTLCqyt+cBvG4fk84XYerqrjv+EcSshJoTCU0YcNIwr45nwLa1lBsKFx dmtdHjnxenFTjUHrkvu+KQsqikg2CyST7bDw43rc0pKScjGwdWOORIp8CLdPsVl/BcLF fnCA== Content-Disposition: inline In-Reply-To: <20190902072542.GN2369@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Peter Zijlstra Cc: Yunsheng Lin , dalias@libc.org, linux-sh@vger.kernel.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, heiko.carstens@de.ibm.com, linuxarm@huawei.com, jiaxun.yang@flygoat.com, linux-mips@vger.kernel.org, mwb@linux.vnet.ibm.com, paulus@samba.org, hpa@zytor.com, sparclinux@vger.kernel.org, chenhc@lemote.com, will@kernel.org, cai@lca.pw, linux-s390@vger.kernel.org, ysato@users.sourceforge.jp, mpe@ellerman.id.au, x86@kernel.org, rppt@linux.ibm.com, borntraeger@de.ibm.com, dledford@redhat.com, mingo@redhat.com, jeffrey.t.kirsher@intel.com, benh@kernel.crashing.org, jhogan@kernel.org, nfont@linux.vnet.ibm.com, mattst88@gmail.com, len.brown@intel.com, gor@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, luto@kernel.org, tglx@linutronix.de, n * Peter Zijlstra wrote: > Also note that the CONFIG_DEBUG_PER_CPU_MAPS version of > cpumask_of_node() already does this (although it wants the below fix). > > --- > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > index e6dad600614c..5f49c10201c7 100644 > --- a/arch/x86/mm/numa.c > +++ b/arch/x86/mm/numa.c > @@ -861,7 +861,7 @@ void numa_remove_cpu(int cpu) > */ > const struct cpumask *cpumask_of_node(int node) > { > - if (node >= nr_node_ids) { > + if ((unsigned)node >= nr_node_ids) { > printk(KERN_WARNING > "cpumask_of_node(%d): node > nr_node_ids(%u)\n", > node, nr_node_ids); Nitpicking: please also fix the kernel message to say ">=". With that: Acked-by: Ingo Molnar Note that: - arch/arm64/mm/numa.c copied the same sign bug (or unrobustness if we don't want to call it a bug). - Kudos to the mm/memcontrol.c and kernel/bpf/syscall.c teams for not copying that bug. Booo for none of them fixing the buggy pattern elsewhere in the kernel ;-) Thanks, Ingo