Re: [PATCH v15 7/7] timers: Exclude isolated cpus from timer migration

From: Frederic Weisbecker

Date: Wed Nov 19 2025 - 15:13:22 EST


Le Wed, Nov 19, 2025 at 07:15:42PM +0100, Thomas Gleixner a écrit :
> On Wed, Nov 19 2025 at 18:14, Frederic Weisbecker wrote:
> > Le Wed, Nov 19, 2025 at 05:50:15PM +0100, Thomas Gleixner a écrit :
> >> But thinking more about it. What's the actual point of moving this 'clear'
> >> out instead of just moving it further down?
> >>
> >> It does not matter at all whether the isol/unisol muck clears an already
> >> cleared bit or not. But it would keep the function name comprehensible
> >> and avoid all this online/offline wrapper nonsense.
> >
> > That was my suggestion.
> >
> > It's because tmigr_clear_cpu_available() and tmigr_set_cpu_available()
> > can now all be called concurrently through the workqueues and race and
> > mess up the cpumask if they all try to clear/set at the same time...
>
> Huch?
>
> cpumask_set_cpu() uses set_bit() and cpumask_clear_cpu() uses
> clear_bit(). Both are atomic and nothing gets messed up.

Urgh, right...

>
> The only undefined case would be if you end up setting/clearing the same
> bit, which would require that the unisol and isol maps overlap. But that
> would be a bug on it's own, no?

Ok.

But then the "unisolate" works must be flushed before this line:

+ /* Set up the mask earlier to avoid races with the migrator CPU */
+ cpumask_andnot(tmigr_available_cpumask, tmigr_available_cpumask, cpumask_isol);

Because that is non-atomic and can race with the cpumask_set_cpu() from the
works, right?

Thanks.

--
Frederic Weisbecker
SUSE Labs