Re: [PATCH 1/2] sched/topology: Annotate RCU pointers properly

From: Valentin Schneider
Date: Thu Jan 04 2024 - 04:54:49 EST


On 03/01/24 13:56, Pierre Gondois wrote:
> Cleanup RCU-related spare errors by annotating RCU pointers.
>
> sched_domains_numa_distance:
> error: incompatible types in comparison expression
> (different address spaces):
> int [noderef] __rcu *
> int *
>
> sched_domains_numa_masks:
> error: incompatible types in comparison expression
> (different address spaces):
> struct cpumask **[noderef] __rcu *
> struct cpumask ***
>
> Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>

That's from when the NUMA topologies were made dynamic, which should be:
Fixes: 0fb3978b0aac ("sched/numa: Fix NUMA topology for systems with CPU-less nodes")
> ---
> kernel/sched/topology.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 10d1391e7416..0342a4f41f09 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1542,8 +1542,8 @@ static int sched_domains_numa_levels;
> static int sched_domains_curr_level;
>
> int sched_max_numa_distance;
> -static int *sched_domains_numa_distance;
> -static struct cpumask ***sched_domains_numa_masks;
> +static int __rcu *sched_domains_numa_distance;
> +static struct cpumask ** __rcu *sched_domains_numa_masks;

I understand that's what sparse is asking for, but that looks odd to me. We
use it as:

rcu_assign_pointer(sched_domains_numa_masks, foo);

so why isn't it

__rcu ***sched_domains_numa_masks;

?

This isn't a pointer to an RCU-protected array of masks, this is an
RCU-protected double array of masks.
> #endif
>
> /*
> --
> 2.25.1