Re: [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>, Andy Gross <agross@xxxxxxxxxx>, David Airlie <airlied@xxxxxxxx>, Alexey Klimov <aklimov@xxxxxxxxxx>, Andi Kleen <ak@xxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>, Amitkumar Karwar <amitkarwar@xxxxxxxxx>, Andrew Lunn <andrew@xxxxxxx>, Andy Shevchenko <andy@xxxxxxxxxxxxx>, Anup Patel <anup.patel@xxxxxxx>, Ard Biesheuvel <ardb@xxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Jens Axboe <axboe@xxxxxx>, bcm-kernel-feedback-list@xxxxxxxxxxxx, Borislav Petkov <bp@xxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx>, Christoph Lameter <cl@xxxxxxxxx>, Daniel Vetter <daniel@xxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, David Laight <David.Laight@xxxxxxxxxx>, Dennis Zhou <dennis@xxxxxxxxxx>, Dinh Nguyen <dinguyen@xxxxxxxxxx>, Geetha sowjanya <gakula@xxxxxxxxxxx>, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, Heiko Carstens <hca@xxxxxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Ian Rogers <irogers@xxxxxxxxxx>, Jason Wessel <jason.wessel@xxxxxxxxxxxxx>, "James E.J. Bottomley" <jejb@xxxxxxxxxxxxx>, Jonathan Cameron <jic23@xxxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Juri Lelli <juri.lelli@xxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Kalle Valo <kvalo@xxxxxxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, Lee Jones <lee.jones@xxxxxxxxxx>, linux-alpha@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, Russell King <linux@xxxxxxxxxxxxxxx>, linux-crypto@xxxxxxxxxxxxxxx, linux-csky@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>, linux-riscv@xxxxxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-snps-arc@xxxxxxxxxxxxxxxxxxx, Andy Lutomirski <luto@xxxxxxxxxx>, Mark Gross <markgross@xxxxxxxxxx>, Mark Rutland <mark.rutland@xxxxxxx>, "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>, Marc Zyngier <maz@xxxxxxxxxx>, Matti Vaittinen <mazziesaccount@xxxxxxxxx>, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>, Mel Gorman <mgorman@xxxxxxx>, Mike Marciniszyn <mike.marciniszyn@xxxxxxxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Marcin Wojtas <mw@xxxxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, "Paul E. McKenney" <paulmck@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Solomon Peachy <pizza@xxxxxxxxxxxx>, Petr Mladek <pmladek@xxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, Randy Dunlap <rdunlap@xxxxxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Roy Pledge <Roy.Pledge@xxxxxxx>, Saeed Mahameed <saeedm@xxxxxxxxxx>, Sagi Grimberg <sagi@xxxxxxxxxxx>, Subbaraya Sundeep <sbhatta@xxxxxxxxxxx>, Stephen Boyd <sboyd@xxxxxxxxxx>, Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>, Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>, Sunil Goutham <sgoutham@xxxxxxxxxxx>, Sudeep Holla <sudeep.holla@xxxxxxx>, Tariq Toukan <tariqt@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, Ulf Hansson <ulf.hansson@xxxxxxxxxx>, Vlastimil Babka <vbabka@xxxxxxx>, Vineet Gupta <vgupta@xxxxxxxxxx>, Vincent Guittot <vincent.guittot@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, Vivien Didelot <vivien.didelot@xxxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Yury Norov <yury.norov@xxxxxxxxx>
- Subject: Re: [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage
- From: Nicholas Piggin <npiggin@xxxxxxxxx>
- Date: Sun, 28 Nov 2021 21:08:41 +1000
- In-reply-to: <20211128035704.270739-1-yury.norov@gmail.com>
- References: <20211128035704.270739-1-yury.norov@gmail.com>
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
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]