Commit f7e30f01 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Thomas Gleixner
Browse files

cpumask: Add helper cpumask_available()

With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
pointer, otherwise a struct cpumask array with a single element.

Some code dealing with cpumasks needs to validate that a cpumask_var_t
is not a NULL pointer when CONFIG_CPUMASK_OFFSTACK=y. This is typically
done by performing the check always, regardless of the underlying type
of cpumask_var_t. This works in both cases, however clang raises a
warning like this when CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'

Add the inline helper cpumask_available() which only performs the
pointer check if CONFIG_CPUMASK_OFFSTACK=y.
Signed-off-by: default avatarMatthias Kaehlcke <>
Cc: Grant Grundler <>
Cc: Rusty Russell <>
Cc: Greg Hackmann <>
Cc: Michael Davidson <>
Cc: Andrew Morton <>

Signed-off-by: default avatarThomas Gleixner <>
parent 45e52022
......@@ -667,6 +667,11 @@ void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
void free_cpumask_var(cpumask_var_t mask);
void free_bootmem_cpumask_var(cpumask_var_t mask);
static inline bool cpumask_available(cpumask_var_t mask)
return mask != NULL;
typedef struct cpumask cpumask_var_t[1];
......@@ -708,6 +713,11 @@ static inline void free_cpumask_var(cpumask_var_t mask)
static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
static inline bool cpumask_available(cpumask_var_t mask)
return true;
/* It's common to want to use cpu_all_mask in struct member initializers,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment