Re: [PATCH] kunit: irq: Ensure timer doesn't fire too frequently

From: Eric Biggers

Date: Tue Feb 24 2026 - 17:51:36 EST


On Mon, Feb 23, 2026 at 07:37:51PM -0800, Eric Biggers wrote:
> Fix a bug where kunit_run_irq_test() could hang if the system is too
> slow. This was noticed with the crypto library tests in certain VMs.
>
> Specifically, if kunit_irq_test_timer_func() and the associated hrtimer
> code took over 5us to run, then the CPU would spend all its time
> executing that code in hardirq context. As a result, the task executing
> kunit_run_irq_test() never had a chance to run, exit the loop, and
> cancel the timer.
>
> To fix it, make kunit_irq_test_timer_func() increase the timer interval
> when the other contexts aren't having a chance to run.
>
> Fixes: 950a81224e8b ("lib/crypto: tests: Add hash-test-template.h and gen-hash-testvecs.py")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
>
> This patch applies to v7.0-rc1 and is targeting libcrypto-fixes
>
> include/kunit/run-in-irq-context.h | 44 +++++++++++++++++++-----------
> 1 file changed, 28 insertions(+), 16 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-fixes

(Additional reviews always appreciated, of course)

- Eric