References: From: Philippe Gerum Subject: Re: [PATCH] x86/hpet: dovetail: Harden clocksource for use in oob In-reply-to: Date: Fri, 18 Jun 2021 09:31:55 +0200 Message-ID: <87fsxf632s.fsf@xenomai.org> MIME-Version: 1.0 Content-Type: text/plain List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Xenomai Jan Kiszka writes: > From: Jan Kiszka > > While it's slow, has scalability issues, it remains the second-best > clocksource for Linux on x86. If Linux decides that the TSC is not > reliable we will end up here and should avoid bringing the system into > an unstable state. > > Suggested-by: Philippe Gerum > Signed-off-by: Jan Kiszka > --- > > While this does not give us hpet for Xenomai yet (vDSO fallback path > still missing), it resolves the system stalls when Linux switches here. > > arch/x86/kernel/hpet.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c > index 67a9f248270c..ce8e15aa8a97 100644 > --- a/arch/x86/kernel/hpet.c > +++ b/arch/x86/kernel/hpet.c > @@ -811,7 +811,7 @@ static u64 read_hpet(struct clocksource *cs) > if (arch_spin_is_locked(&old.lock)) > goto contended; > > - local_irq_save(flags); > + flags = hard_local_irq_save(); > if (arch_spin_trylock(&hpet.lock)) { > new.value = hpet_readl(HPET_COUNTER); > /* > @@ -819,10 +819,10 @@ static u64 read_hpet(struct clocksource *cs) > */ > WRITE_ONCE(hpet.value, new.value); > arch_spin_unlock(&hpet.lock); > - local_irq_restore(flags); > + hard_local_irq_restore(flags); > return (u64)new.value; > } > - local_irq_restore(flags); > + hard_local_irq_restore(flags); > > contended: > /* Tested with EVL v5.10.42 on Atom x5 quad core (1.8 Ghz), with clocksource=hpet forced on the kernel command line, running latmus under stress. All good, although the typical latency is more than two times the one we have with TSC, as expected unfortunately. Nothing pathological, just the combination of slow hpet hardware and non-vDSO access to read it. Merged, thanks. -- Philippe.