Re: [PATCH] LoongArch: Implement stable timer shutdown interface

From: Huacai Chen
Date: Wed Nov 15 2023 - 21:50:19 EST


Hi, Bibo,

"stable timer" is Chinglish, use "constant timer" here.

On Tue, Nov 14, 2023 at 7:49 PM Bibo Mao <maobibo@xxxxxxxxxxx> wrote:
>
> When cpu is hotplug out, cpu is in idle state and function
> arch_cpu_idle_dead is called. Timer interrupt for this processor should
> be disabled, else there will be timer interrupt for the dead cpu. Also
> this prevents vcpu to schedule out during halt-polling flow when system
> is running in vm mode, since there is pending timer interrupt.
>
> This patch adds detailed implementation for timer shutdown interface, so
> that timer will be disabled when cpu is plug-out.
>
> Signed-off-by: Bibo Mao <maobibo@xxxxxxxxxxx>
> ---
> arch/loongarch/kernel/time.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/arch/loongarch/kernel/time.c b/arch/loongarch/kernel/time.c
> index 3064af94db9c..2920770e30a9 100644
> --- a/arch/loongarch/kernel/time.c
> +++ b/arch/loongarch/kernel/time.c
> @@ -58,7 +58,7 @@ static int constant_set_state_oneshot(struct clock_event_device *evt)
> return 0;
> }
>
> -static int constant_set_state_oneshot_stopped(struct clock_event_device *evt)
> +static int constant_set_state_shutdown(struct clock_event_device *evt)
> {
> unsigned long timer_config;
>
Please remove the whole constant_set_state_oneshot_stopped() and move
its logic to the below constant_set_state_shutdown().

And it is very strange that this "bug" hasn't caused any problems until now.

Huacai

> @@ -90,11 +90,6 @@ static int constant_set_state_periodic(struct clock_event_device *evt)
> return 0;
> }
>
> -static int constant_set_state_shutdown(struct clock_event_device *evt)
> -{
> - return 0;
> -}
> -
> static int constant_timer_next_event(unsigned long delta, struct clock_event_device *evt)
> {
> unsigned long timer_config;
> @@ -161,7 +156,7 @@ int constant_clockevent_init(void)
> cd->rating = 320;
> cd->cpumask = cpumask_of(cpu);
> cd->set_state_oneshot = constant_set_state_oneshot;
> - cd->set_state_oneshot_stopped = constant_set_state_oneshot_stopped;
> + cd->set_state_oneshot_stopped = constant_set_state_shutdown;
> cd->set_state_periodic = constant_set_state_periodic;
> cd->set_state_shutdown = constant_set_state_shutdown;
> cd->set_next_event = constant_timer_next_event;
>
> base-commit: 9bacdd8996c77c42ca004440be610692275ff9d0
> --
> 2.39.3
>