On 26/08/2024 11:37 am, Jan Beulich wrote: > On 23.08.2024 01:06, Andrew Cooper wrote: >> Using hweight() is an especially expensive way of determining simply if >> multiple bits are set in a value. Worse, 4 of the 10 hweight() calls in Xen >> are of this form. >> >> Switch to the new multiple_bits_set() helper. This is far more efficient >> than >> the longhand hweight() algorithm and, owing to its simplicity, likely more >> efficient than even a dedicated instruction on a superscalar processor. >> >> No functional change. >> >> Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> > Reviewed-by: Jan Beulich <jbeul...@suse.com>
Thanks. > > Just to mention it: With the title being sufficiently generic, I half > expected the similar {bitmap,cpumask}_weight() to also be taken care of. > Yet certainly those (and maybe also their ... == 1 forms) can be covered > later. They are on my radar, but are not as easy to transform. We'd need a new bitmap API to optimise this case; looking at the callers, it is definitely worth optimising. There are also an awful lot of cpumask_weight() == 1 which want converting, albeit slightly differently. That's a full series of work in and of itself. ~Andrew