On Thu, Feb 06, 2020 at 04:34:34PM -0800, Martin KaFai Lau wrote: > On Thu, Feb 06, 2020 at 03:47:21PM -0800, Linus Torvalds wrote: > > > > Instead, it could just calculate the nbuckets first, and then do the > > "log2()" on that: > > > > /* Use at least 2 buckets, select_bucket() is undefined > > behavior with 1 bucket */ > > nbuckets = max_t(u32, 2, roundup_pow_of_two(num_possible_cpus())); > > smap->bucket_log = ilog2(buckets); > > > > because honestly, that is just a whole lot more legible anyway. Maybe > > even split _that_ up, and have the max_t as a separate thing. > Thanks for the suggestion. I can post a patch for this. There is also order_base_2() which, I think, does exactly what you need and shouldn't have the current problem. -- Luc