Re: [PATCH v3 sched_ext/for-6.13] sched_ext: Do not enable LLC/NUMA optimizations when domains overlap

From: Nathan Chancellor
Date: Fri Nov 08 2024 - 13:18:01 EST


Hi Andrea,

On Fri, Nov 08, 2024 at 01:01:36AM +0100, Andrea Righi wrote:
...
> + /*
> + * Enable NUMA optimization only when there are multiple NUMA domains
> + * among the online CPUs and the NUMA domains don't perfectly overlaps
> + * with the LLC domains.
> + *
> + * If all CPUs belong to the same NUMA node and the same LLC domain,
> + * enabling both NUMA and LLC optimizations is unnecessary, as checking
> + * for an idle CPU in the same domain twice is redundant.
> + */
> + cpus = cpumask_of_node(cpu_to_node(cpu));
> + if ((cpumask_weight(cpus) < num_online_cpus()) & llc_numa_mismatch())
> + enable_numa = true;

With this hunk in next-20241108, I am seeing a clang warning (or error
since CONFIG_WERROR=y):

In file included from kernel/sched/build_policy.c:63:
kernel/sched/ext.c:3252:6: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
3252 | if ((cpumask_weight(cpus) < num_online_cpus()) & llc_numa_mismatch())
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| &&
kernel/sched/ext.c:3252:6: note: cast one or both operands to int to silence this warning
1 error generated.

Was use of a bitwise AND here intentional (i.e., should
llc_num_mismatch() always be called regardless of the outcome of the
first condition) or can it be switched to a logical AND to silence the
warning? I do not mind sending a patch but I did not want to be wrong
off bat. If there is some other better solution that I am not seeing,
please feel free to send a patch with this as just a report.

Cheers,
Nathan