[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdnQ9feXGYV2CUyVwg-FNAOmb4HBmDxMg243v28DzSfLuA@mail.gmail.com>
Date: Wed, 29 Mar 2023 10:30:51 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Johannes Berg <johannes@...solutions.net>
Cc: Nathan Chancellor <nathan@...nel.org>, gregory.greenman@...el.com,
kvalo@...nel.org, trix@...hat.com, avraham.stern@...el.com,
krishnanand.prabhu@...el.com, linux-wireless@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, patches@...ts.linux.dev,
Arnd Bergmann <arnd@...db.de>,
"kernelci.org bot" <bot@...nelci.org>,
Craig Topper <craig.topper@...ive.com>
Subject: Re: [PATCH wireless-next] wifi: iwlwifi: mvm: Avoid 64-bit division
in iwl_mvm_get_crosstimestamp_fw()
On Wed, Mar 29, 2023 at 10:20 AM Johannes Berg
<johannes@...solutions.net> wrote:
>
> On Wed, 2023-03-29 at 10:05 -0700, Nathan Chancellor wrote:
> >
> > GCC has optimizations for division by a constant that clang does not
> > implement, so this issue is not visible when building with GCC.
>
> Huh yeah, we did 32-bit builds with gcc ...
Right, GCC is better about turning division by double-word constant
into multiplication by reciprocal. Craig has been improving LLVM, but
it seems that some divisors still aren't supported (in this case 100).
>
> > Using div_u64() would resolve this issue, but Arnd points out that this
> > can be quite expensive and the timestamp is being read at nanosecond
> > granularity.
>
> Doesn't matter though, all the calculations are based on just the
> command response from the firmware, which (tries to) take it in a
> synchronised fashion.
>
> So taking more time here would be fine, as far as I can tell.
div_u64() it is then.
>
> > Nick pointed out that the result of this division is being
> > stored to a 32-bit type anyways, so truncate gp2_10ns first then do the
> > division, which elides the need for libcalls.
>
> That loses ~7 top bits though, no? I'd be more worried about that, than
> the time div_u64() takes.
The result is still stored in a u32; there is a loss of precision
regardless of use of div_u64 or open coded binary operator /. So is
the loss of precision before the division as tolerable as after the
division?
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists