RE: [PATCH v2 2/2] mul_u64_u64_div_u64: basic sanity test

From: Biju Das
Date: Thu Jul 04 2024 - 02:40:57 EST


Hi All,

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
> Sent: Wednesday, July 3, 2024 10:36 PM
> Subject: Re: [PATCH v2 2/2] mul_u64_u64_div_u64: basic sanity test
>
> Hello Andrew,
>
> On Wed, Jul 03, 2024 at 01:47:10PM -0400, Nicolas Pitre wrote:
> > On Wed, 3 Jul 2024, Andrew Morton wrote:
> >
> > > On Tue, 2 Jul 2024 23:34:09 -0400 Nicolas Pitre <nico@xxxxxxxxxxx> wrote:
> > >
> > > > Verify that edge cases produce proper results, and some more.
> > >
> > > Awesome, thanks.
> > >
> > > Do you know of any situations in which the present implementation
> > > causes issues?
> >
> > Uwe could probably elaborate further, but the example given in the
> > first commit log is causing trouble for a driver he's working on.
>
> Actually the example was a constructed one. I became aware of
> mul_u64_u64_div_u64() being only an approximation while reviewing a pwm driver by Biju Das:
>
> https://lore.kernel.org/linux-
> pwm/TYCPR01MB1126992DD51F714AEDADF0A4F868DA@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> mul_u64_u64_div_u64 is used in various pwm drivers, but in practise the periods used are small enough
> to not be problematic for the status quo implementation since commit 8c86fb68ffcb
> ("mul_u64_u64_div_u64: increase precision by conditionally swapping a and b"). At least I think Biju
> (added to Cc:) only hit this problem during testing, and not in a real world application.
>
> I intend to do a performance test of Nico's code. I hope I get to that tomorrow.

I should be able to test the new patch[1] with [2] as mul_u64_u64_div_u64() used in [2].

[1] https://lkml.org/lkml/2024/6/28/1130
[2] https://lore.kernel.org/linux-renesas-soc/20240614154242.419043-1-biju.das.jz@xxxxxxxxxxxxxx/

I will test and provide feedback soon.

Cheers,
Biju