All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/hpet: dovetail: Harden clocksource for use in oob
@ 2021-06-18  6:29 Jan Kiszka
  2021-06-18  7:31 ` Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2021-06-18  6:29 UTC (permalink / raw)
  To: Xenomai, Philippe Gerum

From: Jan Kiszka <jan.kiszka@siemens.com>

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 <rpm@xenomai.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

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:
 	/*
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/hpet: dovetail: Harden clocksource for use in oob
  2021-06-18  6:29 [PATCH] x86/hpet: dovetail: Harden clocksource for use in oob Jan Kiszka
@ 2021-06-18  7:31 ` Philippe Gerum
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2021-06-18  7:31 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai


Jan Kiszka <jan.kiszka@siemens.com> writes:

> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> 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 <rpm@xenomai.org>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> 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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-18  7:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  6:29 [PATCH] x86/hpet: dovetail: Harden clocksource for use in oob Jan Kiszka
2021-06-18  7:31 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.