Re: [PATCH 3/4] cpumask: Convert cpumask_any_but() to the new random function

From: Steven Rostedt
Date: Tue Apr 14 2020 - 12:28:19 EST


On Tue, 14 Apr 2020 16:05:55 +0100
Qais Yousef <qais.yousef@xxxxxxx> wrote:

> +int cpumask_any_but(const struct cpumask *srcp, unsigned int cpu)
> +{
> + unsigned int i;
> +
> + cpumask_check(cpu);
> +
> + for_each_cpu(i, srcp) {
> + i = cpumask_any(srcp);

Hmm, if the current CPU is the last CPU in the mask, and cpumask_any()
happens to return it, what happens?

> + if (i != cpu)
> + return i;

We loop again, and wouldn't i being the last CPU in the mask cause this
loop to exit, and return nr_cpu_ids?

-- Steve

> + }
> +
> + return nr_cpu_ids;
> +}