lkml.org 
[lkml]   [2021]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage
    On Sun, Nov 28, 2021 at 09:08:41PM +1000, Nicholas Piggin wrote:
    > Excerpts from Yury Norov's message of November 28, 2021 1:56 pm:
    > > In many cases people use bitmap_weight()-based functions like this:
    > >
    > > if (num_present_cpus() > 1)
    > > do_something();
    > >
    > > This may take considerable amount of time on many-cpus machines because
    > > num_present_cpus() will traverse every word of underlying cpumask
    > > unconditionally.
    > >
    > > We can significantly improve on it for many real cases if stop traversing
    > > the mask as soon as we count present cpus to any number greater than 1:
    > >
    > > if (num_present_cpus_gt(1))
    > > do_something();
    > >
    > > To implement this idea, the series adds bitmap_weight_{eq,gt,le}
    > > functions together with corresponding wrappers in cpumask and nodemask.
    >
    > There would be no change to callers if you maintain counters like what
    > is done for num_online_cpus() today. Maybe some fixes to arch code that
    > does not use set_cpu_possible() etc APIs required, but AFAIKS it would
    > be better to fix such cases anyway.

    Thanks, Nick. I'll try to do this.

    \
     
     \ /
      Last update: 2021-11-29 00:38    [W:4.163 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site