[lkml]   [2018]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.9 018/102] cpumask: Add helper cpumask_available()
4.9-stable review patch.  If anyone has any objections, please let me know.


From: Matthias Kaehlcke <>

commit f7e30f01a9e221067bb4b579e3cfc25cd2617467 upstream.

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: Matthias Kaehlcke <>
Cc: Grant Grundler <>
Cc: Rusty Russell <>
Cc: Greg Hackmann <>
Cc: Michael Davidson <>
Cc: Andrew Morton <>
Signed-off-by: Thomas Gleixner <>
Cc: Nathan Chancellor <>
Signed-off-by: Greg Kroah-Hartman <>

include/linux/cpumask.h | 10 ++++++++++
1 file changed, 10 insertions(+)

--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -680,6 +680,11 @@ void alloc_bootmem_cpumask_var(cpumask_v
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];

@@ -720,6 +725,11 @@ static inline void free_cpumask_var(cpum
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,

 \ /
  Last update: 2018-04-06 16:50    [W:0.246 / U:1.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site