From: Ingo Molnar <mingo@kernel.org> To: Siddh Raman Pant <code@siddh.me> Cc: x86 <x86@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Andy Lutomirski <luto@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>, linux-kernel <linux-kernel@vger.kernel.org>, linux-kernel-mentees <linux-kernel-mentees@lists.linuxfoundation.org> Subject: Re: [PATCH] x86/numa: Use cpumask_available instead of hardcoded NULL check Date: Wed, 3 Aug 2022 11:42:11 +0200 [thread overview] Message-ID: <YupC88xuQ4rcyLVR@gmail.com> (raw) In-Reply-To: <18263030220.8a990e82436929.3216192040531777412@siddh.me> * Siddh Raman Pant <code@siddh.me> wrote: > On Wed, 03 Aug 2022 14:38:19 +0530 Ingo Molnar <mingo@kernel.org> wrote: > > > > * Siddh Raman Pant <code@siddh.me> wrote: > > > There is no reason why allmodconfig would trigger the warning, [...] > > > > Well, unless I'm misreading your changelog, all the warning needs to > > trigger is CONFIG_CPUMASK_OFFSTACK=y. > > > > > as it has CONFIG_CPUMASK_OFFSTACK=y, but the warning is because of the > > > other case. > > > > What 'other case'? I've re-read the discussion and don't see it, but maybe > > I'm a bit daft this morning ... > > No, the warning is happening because CONFIG_CPUMASK_OFFSTACK is not set. Oh. So I was daft, as suspected. ;-) And I can confirm that while gcc-11 doesn't trigger the warning, gcc-12 does: $ make ARCH=x86_64 CC=gcc-11 arch/x86/mm/numa.o CC arch/x86/mm/numa.o $ $ rm -f arch/x86/mm/numa.o $ $ make ARCH=x86_64 CC=gcc-12 arch/x86/mm/numa.o CC arch/x86/mm/numa.o arch/x86/mm/numa.c: In function ‘cpumask_of_node’: arch/x86/mm/numa.c:916:39: error: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Werror=address] 916 | if (node_to_cpumask_map[node] == NULL) { > [...] This is because in that case cpumask_var_t type is not a pointer, > and thus the var can never be NULL, which leads gcc to warn us when > comparing with NULL. > > The chain of events are like: > > #ifdef CONFIG_CPUMASK_OFFSTACK > typedef struct cpumask *cpumask_var_t; > #else > typedef struct cpumask cpumask_var_t[1]; > endif > > cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; > ... > if (node_to_cpumask_map[node] == NULL) { > > > The fix works because: > > #ifdef CONFIG_CPUMASK_OFFSTACK > static inline bool cpumask_available(cpumask_var_t mask) > { > return mask != NULL; > } > #else > static inline bool cpumask_available(cpumask_var_t mask) > { > return true; > } > endif > > > The conditional definitions, as pointed out earlier, can be seen from line 700 > of include/linux/cpumask.h file. Yeah - and I agree with your fix - will apply it. Thanks for your patience :-) Ingo
WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@kernel.org> To: Siddh Raman Pant <code@siddh.me> Cc: Dave Hansen <dave.hansen@linux.intel.com>, Peter Zijlstra <peterz@infradead.org>, x86 <x86@kernel.org>, linux-kernel <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel-mentees <linux-kernel-mentees@lists.linuxfoundation.org> Subject: Re: [PATCH] x86/numa: Use cpumask_available instead of hardcoded NULL check Date: Wed, 3 Aug 2022 11:42:11 +0200 [thread overview] Message-ID: <YupC88xuQ4rcyLVR@gmail.com> (raw) In-Reply-To: <18263030220.8a990e82436929.3216192040531777412@siddh.me> * Siddh Raman Pant <code@siddh.me> wrote: > On Wed, 03 Aug 2022 14:38:19 +0530 Ingo Molnar <mingo@kernel.org> wrote: > > > > * Siddh Raman Pant <code@siddh.me> wrote: > > > There is no reason why allmodconfig would trigger the warning, [...] > > > > Well, unless I'm misreading your changelog, all the warning needs to > > trigger is CONFIG_CPUMASK_OFFSTACK=y. > > > > > as it has CONFIG_CPUMASK_OFFSTACK=y, but the warning is because of the > > > other case. > > > > What 'other case'? I've re-read the discussion and don't see it, but maybe > > I'm a bit daft this morning ... > > No, the warning is happening because CONFIG_CPUMASK_OFFSTACK is not set. Oh. So I was daft, as suspected. ;-) And I can confirm that while gcc-11 doesn't trigger the warning, gcc-12 does: $ make ARCH=x86_64 CC=gcc-11 arch/x86/mm/numa.o CC arch/x86/mm/numa.o $ $ rm -f arch/x86/mm/numa.o $ $ make ARCH=x86_64 CC=gcc-12 arch/x86/mm/numa.o CC arch/x86/mm/numa.o arch/x86/mm/numa.c: In function ‘cpumask_of_node’: arch/x86/mm/numa.c:916:39: error: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Werror=address] 916 | if (node_to_cpumask_map[node] == NULL) { > [...] This is because in that case cpumask_var_t type is not a pointer, > and thus the var can never be NULL, which leads gcc to warn us when > comparing with NULL. > > The chain of events are like: > > #ifdef CONFIG_CPUMASK_OFFSTACK > typedef struct cpumask *cpumask_var_t; > #else > typedef struct cpumask cpumask_var_t[1]; > endif > > cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; > ... > if (node_to_cpumask_map[node] == NULL) { > > > The fix works because: > > #ifdef CONFIG_CPUMASK_OFFSTACK > static inline bool cpumask_available(cpumask_var_t mask) > { > return mask != NULL; > } > #else > static inline bool cpumask_available(cpumask_var_t mask) > { > return true; > } > endif > > > The conditional definitions, as pointed out earlier, can be seen from line 700 > of include/linux/cpumask.h file. Yeah - and I agree with your fix - will apply it. Thanks for your patience :-) Ingo _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2022-08-03 9:42 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-31 16:09 [PATCH] x86/numa: Use cpumask_available instead of hardcoded NULL check Siddh Raman Pant via Linux-kernel-mentees 2022-07-31 16:09 ` Siddh Raman Pant 2022-08-02 11:07 ` Ingo Molnar 2022-08-02 11:07 ` Ingo Molnar 2022-08-02 16:29 ` Siddh Raman Pant via Linux-kernel-mentees 2022-08-02 16:29 ` Siddh Raman Pant 2022-08-03 8:48 ` Ingo Molnar 2022-08-03 8:48 ` Ingo Molnar 2022-08-03 8:58 ` Siddh Raman Pant via Linux-kernel-mentees 2022-08-03 8:58 ` Siddh Raman Pant 2022-08-03 9:08 ` Ingo Molnar 2022-08-03 9:08 ` Ingo Molnar 2022-08-03 9:21 ` Siddh Raman Pant 2022-08-03 9:21 ` Siddh Raman Pant via Linux-kernel-mentees 2022-08-03 9:42 ` Ingo Molnar [this message] 2022-08-03 9:42 ` Ingo Molnar 2022-08-03 9:46 ` Siddh Raman Pant via Linux-kernel-mentees 2022-08-03 9:46 ` Siddh Raman Pant 2022-08-03 15:41 ` [tip: x86/urgent] " tip-bot2 for Siddh Raman Pant
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YupC88xuQ4rcyLVR@gmail.com \ --to=mingo@kernel.org \ --cc=bp@alien8.de \ --cc=code@siddh.me \ --cc=dave.hansen@linux.intel.com \ --cc=hpa@zytor.com \ --cc=linux-kernel-mentees@lists.linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=luto@kernel.org \ --cc=mingo@redhat.com \ --cc=peterz@infradead.org \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.