Re: [PATCH v3] clocksource: Replace loop within clocks_calc_mult_shift() with find_last_bit() for calculation of "sftacc"

Yury Norov
2025-06-11T14:30:39Z

On Wed, Jun 11, 2025 at 10:26:39PM +0800, I Hsin Cheng wrote:
> line
> In-Reply-To: <aEltbEpA7US9h8qN@yury>
> Status: O
> Content-Length: 5191
> Lines: 144
>
> On Wed, Jun 11, 2025 at 07:50:04AM -0400, Yury Norov wrote:
> > On Wed, Jun 11, 2025 at 03:36:08PM +0800, I Hsin Cheng wrote:

> Hi Yury,
>
> Thanks for your suggestions !
>
> > 1. sftacc is known to be 32. Comparing against 0 is useless.
> > 2. Just use __fls():
> > if (tmp)
> > sftacc -=__fls(tmp) + 1;
> >
>
> No problem, I'll fix them up in the next version.
> Just wondering the reason to use __fls() directly, is it because we're
> sure that the value of "tmp" will definitely fall into
> small_const_nbits() case in find_last_bit() ?

That's because tmp is not a bitmap. It's u64.