lkml.org 
[lkml]   [2022]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/numa: Use cpumask_available instead of hardcoded NULL check
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. 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.

> > Did you try the config file I had linked to earlier?
>
> Yes, and it didn't trigger the warning.
>
> Thanks,
>
> Ingo
>

Thanks,
Siddh

\
 
 \ /
  Last update: 2022-08-03 11:24    [W:0.064 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site