Skip to content

Commit e90bc78

Browse files
Eric Biggersgregkh
authored andcommitted
kunit: irq: Continue increasing hrtimer interval for longer
commit faa6c4c upstream. Currently, kunit_irq_test_timer_func() stops increasing the hrtimer interval as soon as some forward progress is made in each of softirq and task context. Update it to use a more aggressive strategy: increase the interval as long as the hrtimer is running significantly faster than either context. This resolves an occasional hang in the CRC and crypto library tests under qemu-system-s390x. It was exposed by the change in the default preemption model on s390 from NONE to LAZY. That seems to have exposed the issue by allowing some forward progress to be made while the actual system timer tick is still starved, preventing jiffies from increasing or the task context from making much progress towards max_iterations. Fixes: 201ceb9 ("kunit: irq: Ensure timer doesn't fire too frequently") Cc: stable@vger.kernel.org Reviewed-by: David Gow <david@davidgow.net> Acked-by: Ard Biesheuvel <ardb@kernel.org> Link: https://patch.msgid.link/20260803181842.44648-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 34f3c35 commit e90bc78

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

include/kunit/run-in-irq-context.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ static enum hrtimer_restart kunit_irq_test_timer_func(struct hrtimer *timer)
3838
softirq_calls = atomic_read(&state->softirq_func_calls);
3939

4040
/*
41-
* If the timer is firing too often for the softirq or task to ever have
42-
* a chance to run, increase the timer interval. This is needed on very
43-
* slow systems.
41+
* If the hrtimer is running much faster than the bh_work or the task,
42+
* then it is firing too fast and might be starving those contexts as
43+
* well as the actual system timer tick. Increase the interval.
4444
*/
45-
if (hardirq_calls >= 20 && (softirq_calls == 0 || task_calls == 0))
45+
if (hardirq_calls >= 20 &&
46+
(hardirq_calls / 2 > softirq_calls ||
47+
hardirq_calls / 2 > task_calls))
4648
state->interval = ktime_add_ns(state->interval, 250);
4749

4850
if (!state->func(state->test_specific_state))

0 commit comments

Comments
 (0)