Patch "x86/numa: Use cpumask_available instead of hardcoded NULL check" has been added to the 4.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/numa: Use cpumask_available instead of hardcoded NULL check

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-numa-use-cpumask_available-instead-of-hardcoded-.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ee4776aaa37caf0fc48694aaf957d1ae35a27542
Author: Siddh Raman Pant <code@xxxxxxxx>
Date:   Sun Jul 31 21:39:13 2022 +0530

    x86/numa: Use cpumask_available instead of hardcoded NULL check
    
    [ Upstream commit 625395c4a0f4775e0fe00f616888d2e6c1ba49db ]
    
    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@xxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220731160913.632092-1-code@xxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 3f35b48d1d9d..4249bae6e404 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -826,7 +826,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;
@@ -872,7 +872,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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux