Re: [PATCH] refperf: work around 64-bit division

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 30, 2020 at 5:52 AM Nathan Chancellor
<natechancellor@xxxxxxxxx> wrote:
> On Fri, May 29, 2020 at 10:15:51PM +0200, Arnd Bergmann wrote:
> >       strcat(buf, "Threads\tTime(ns)\n");
> >
> >       for (exp = 0; exp < nruns; exp++) {
> > +             u64 avg;
> > +             u32 rem;
> > +
> >               if (errexit)
> >                       break;
> > -             sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, result_avg[exp] / 1000, (int)(result_avg[exp] % 1000));
> > +
> > +             avg = div_s64_rem(result_avg[exp], 1000, &rem);
>
> Shouldn't this be div_u64_rem? result_avg is u64.

Yes, you are right. Actually that would be an important optimization
since div_u64_rem() optimizes for constant divisors while div_s64_rem
uses the slow path.

> > +             sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, avg, rem);
>
> Would %03u be the better specifier since rem is u32?

Yes, though this makes no difference in practice.

Paul, should I send a fixup for these two, or do you prefer to just
edit it in place?

    Arnd



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux