On 06/02/2022 19:40, Julien Grall wrote: > Hi, > > On 04/02/2022 20:31, Andrew Cooper wrote: >> cpumask_weight() is a horribly expensive way to find if no bits are >> set, made >> worse by the fact that the calculation is performed with the global >> call_lock >> held. > > I looked at the archive because I was wondering why we were using > cpumask_weight here. It looks like this was a left-over of the rework > in ac3fc35d919c "x86: Fix flush_area_mask() and on_selected_cpus() to > not race updates".
That change shuffled the code, but didn't introduce the problem. I'm pretty sure it was 433f14699d48 which dropped the !=0 user of nr_cpus. Talking of, there is more efficiency to be gained by reworking the second cpumask_empty() call to not restart from 0 on failure, because that removes useless reads. > >> >> Switch to using cpumask_empty() instead, which will short circuit as >> soon as >> it find any set bit in the cpumask. >> >> Signed-off-by: Andrew Cooper <[email protected]> > > Reviewed-by: Julien Grall <[email protected]> Thanks. ~Andrew
