[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1329105a-aa6b-bd40-3a62-5c7e130d2a7b@c-s.fr>
Date: Wed, 29 Jan 2020 08:26:39 +0100
From: Christophe Leroy <christophe.leroy@....fr>
To: Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>, nathanl@...ux.ibm.com,
Arnd Bergmann <arnd@...db.de>,
Vincenzo Frascino <vincenzo.frascino@....com>,
LKML <linux-kernel@...r.kernel.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
"open list:MIPS" <linux-mips@...r.kernel.org>,
X86 ML <x86@...nel.org>
Subject: Re: [RFC PATCH v4 10/11] lib: vdso: Allow arches to override the ns
shift operation
Le 29/01/2020 à 08:14, Thomas Gleixner a écrit :
> Andy Lutomirski <luto@...nel.org> writes:
>
>> On Thu, Jan 16, 2020 at 11:57 AM Thomas Gleixner <tglx@...utronix.de> wrote:
>>>
>>> Andy Lutomirski <luto@...nel.org> writes:
>>>> On Thu, Jan 16, 2020 at 9:58 AM Christophe Leroy
>>>>
>>>> Would mul_u64_u64_shr() be a good alternative? Could we adjust it to
>>>> assume the shift is less than 32? That function exists to benefit
>>>> 32-bit arches.
>>>
>>> We'd want mul_u64_u32_shr() for this. The rules for mult and shift are:
>>>
>>
>> That's what I meant to type...
>
> Just that it does not work. The math is:
>
> ns = d->nsecs; // That's the nsec value shifted left by d->shift
>
> ns += ((cur - d->last) & d->mask) * mult;
>
> ns >>= d->shift;
>
> So we cannot use mul_u64_u32_shr() because we need the addition there
> before shifting. And no, we can't drop the fractional part of
> d->nsecs. Been there, done that, got sporadic time going backwards
> problems as a reward. Need to look at that again as stuff has changed
> over time.
>
> On x86 we enforce that mask is 64bit, so the & operation is not there,
> but due to the nasties of TSC we have that conditional
>
> if (cur > last)
> return (cur - last) * mult;
> return 0;
>
> Christophe, on PPC the decrementer/RTC clocksource masks are 64bit as
> well, so you can spare that & operation there too.
>
Yes, I did it already. It spares reading d->mast, that the main advantage.
Christophe
Powered by blists - more mailing lists