From: "tip-bot2 for Siddh Raman Pant" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Siddh Raman Pant <code@siddh.me>, Ingo Molnar <mingo@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/numa: Use cpumask_available instead of hardcoded NULL check
Date: Wed, 03 Aug 2022 15:41:58 -0000 [thread overview]
Message-ID: <165954131875.15455.15679349125656470840.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20220731160913.632092-1-code@siddh.me>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 625395c4a0f4775e0fe00f616888d2e6c1ba49db
Gitweb: https://git.kernel.org/tip/625395c4a0f4775e0fe00f616888d2e6c1ba49db
Author: Siddh Raman Pant <code@siddh.me>
AuthorDate: Sun, 31 Jul 2022 21:39:13 +05:30
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 03 Aug 2022 11:44:57 +02:00
x86/numa: Use cpumask_available instead of hardcoded NULL check
GCC-12 started triggering a new warning:
arch/x86/mm/numa.c: In function ‘cpumask_of_node’:
arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress]
916 | if (node_to_cpumask_map[node] == NULL) {
| ^~
node_to_cpumask_map is of type cpumask_var_t[].
When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a
pointer for dynamic allocation, else to an array of one element. The
"wicked game" can be checked on line 700 of include/linux/cpumask.h.
The original code in debug_cpumask_set_cpu() and cpumask_of_node() were
probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y
(i.e. dynamic allocation) in mind, checking if the cpumask was available
via a direct NULL check.
When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning
while compiling the kernel.
Fix that by using cpumask_available(), which does the NULL check when
CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever
such checks are made.
Conditional definitions of cpumask_available() can be found along with
the definition of cpumask_var_t. Check the cpumask.h reference mentioned
above.
Fixes: c032ef60d1aa ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t")
Fixes: de2d9445f162 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit")
Signed-off-by: Siddh Raman Pant <code@siddh.me>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20220731160913.632092-1-code@siddh.me
---
arch/x86/mm/numa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index e8b0615..2aadb20 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -867,7 +867,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)
return;
}
mask = node_to_cpumask_map[node];
- if (!mask) {
+ if (!cpumask_available(mask)) {
pr_err("node_to_cpumask_map[%i] NULL\n", node);
dump_stack();
return;
@@ -913,7 +913,7 @@ const struct cpumask *cpumask_of_node(int node)
dump_stack();
return cpu_none_mask;
}
- if (node_to_cpumask_map[node] == NULL) {
+ if (!cpumask_available(node_to_cpumask_map[node])) {
printk(KERN_WARNING
"cpumask_of_node(%d): no node_to_cpumask_map!\n",
node);
prev parent reply other threads:[~2022-08-03 15:42 UTC|newest]
Thread overview: 10+ 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
2022-08-02 11:07 ` Ingo Molnar
2022-08-02 16:29 ` Siddh Raman Pant
2022-08-03 8:48 ` Ingo Molnar
2022-08-03 8:58 ` Siddh Raman Pant
2022-08-03 9:08 ` Ingo Molnar
2022-08-03 9:21 ` Siddh Raman Pant
2022-08-03 9:42 ` Ingo Molnar
2022-08-03 9:46 ` Siddh Raman Pant
2022-08-03 15:41 ` tip-bot2 for Siddh Raman Pant [this message]
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=165954131875.15455.15679349125656470840.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=code@siddh.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).