Re: [PATCH RFC 1/2] hrtimer: support hrtimer suspend when CPU suspend

From: Thomas Gleixner
Date: Tue Aug 10 2021 - 10:58:21 EST


On Tue, Jun 22 2021 at 17:06, Wang Qing wrote:
> /**
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 4a66725..db34c9d
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -513,7 +513,8 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
>
> next = timerqueue_getnext(&base->active);
> timer = container_of(next, struct hrtimer, node);
> - if (timer == exclude) {
> + if ((timer == exclude) ||
> + (tick_nohz_tick_inidle() && timer->is_suspend)) {

Aside of being indented in unreadable ways, how is this supposed to be
correct? If the first expiring timer is excluded what prevents the next
one from being marked to stop in suspend or the other way round.

What's wrong with just canceling the offending timer before going into
suspend and rearming it on resume instead of adding a half baken magic
case for timers?

Thanks,

tglx