Re: [PATCH] softirq: wake up ktimer thread in softirq context

Alison Chaiken
2022-12-20T19:28:49Z

On 2022-12-20 10:44:07 [+0000], Chang, Junxiao wrote:
> > Any comment? This patch is for 6.1-rt, issue could be reproduced with 5.19-rt kernel as well.

On Tue, Dec 20, 2022 at 10:03 AM bigeasy@linutronix.de
<bigeasy@linutronix.de> wrote:
> Thanks for the ping. I did see the initial email and I didn't get to it
> yet. I need to re-test, confirm and then apply.
> The ktimer patch is not in v5.15 and this is currently the latest one
> maintained by the stable team. I don't know which one will be the
> following LTS kernel but this one needs to have this addressed. The
> v5.19 is not receiving any updates.

We backported the timersd patch to 5.15, where is where we have
observed the C-state transition despite pending timers. The
reported trace sequence does show that __do_softirq() starts just
before the hrtimer_interrupt when the problem occurs:

When the timers are delayed, the trouble appears to begin when the
hrtimer_interrupt results in execution of hrtimer_run_queues() instead
of raise_hrtimer_softirq():
<userspace>-13534 [007] 16947.069504: enqueue_hrtimer
<idle>-0 [007] 16947.069547:
hrtimer_next_event_without: 16947.067643167
<idle>-0 [007] 16947.069553: enqueue_hrtimer
<idle>-0 [007] 16947.069567: enqueue_hrtimer
<idle>-0 [007] 16947.069575:
hrtimer_next_event_without: 16947.067643167
<idle>-0 [007] 16947.069579: enqueue_hrtimer
<idle>-0 [007] 16947.078270: hrtimer_interrupt
<idle>-0 [007] 16947.078278: hrtimer_run_queues.
<idle>-0 [007] 16947.078300: enqueue_hrtimer
ktimers/7-80 [007] 16947.078308: __do_softirq
ksoftirqd/7-81 [007] 16947.078338: ksoftirqd_should_run 0
<idle>-0 [007] 16947.078361:
hrtimer_next_event_without: 16947.067643167
<idle>-0 [007] 16947.079323: hrtimer_interrupt
<idle>-0 [007] 16947.079328: hrtimer_run_queues.
<idle>-0 [007] 16947.079334: enqueue_hrtimer
ksoftirqd/7-81 [007] 16947.079359: ksoftirqd_should_run 128
ksoftirqd/7-81 [007] 16947.079360: __do_softirq
ksoftirqd/7-81 [007] 16947.079361: hrtimer_interrupt
ksoftirqd/7-81 [007] 16947.079361: raise_hrtimer_softirq.
ksoftirqd/7-81 [007] 16947.079364: ksoftirqd_should_run 0
<idle>-0 [007] 16947.079375:
hrtimer_next_event_without: 9223372036854775807
<idle>-0 [007] 16947.079376:
tick_nohz_get_sleep_length: 86.838 ms
<idle>-0 [007] 16947.079378: enqueue_hrtimer

Note the bogus value printed by hrtimer_next_event_without().

> Given the current timing, I will look into this in January.
>
> > Regards,
> > Junxiao
>
> Sebastian

-- Alison Chaiken
Aurora Innovation