On Mon, 29 Apr 2024 at 07:48, Matthew Wilcox (Oracle) willy@infradead.org wrote:
bits_per() rounds up to the next power of two when passed a power of two. This causes crashes on some machines and configurations.
Bah. Your patch is *still* wrong, because bits_per() thinks you need one bit for a zero value, so when you do
bits_per(CONFIG_NR_CPUS - 1)
and some insane person has enabled SMP and managed to set CONFIG_NR_CPUS to 1, the math is *still* broken.
The right thing to do is
order_base_2(CONFIG_NR_CPUS)
and 'bits_per()' should be avoided, having completely crazy semantics (you can tell how almost all users actually do "x-1" as the argument).
We should probably get rid of that horrid bits_per(() entirely.
I applied your patch with that fixed (which admittedly make it all *my* patch, but applying it as yours just to get the changelog).
Linus