Re: CPU Lockups in KVM with deferred hrtimer rearming

Thomas Gleixner
2026-04-20T15:00:13Z

On Thu, Apr 16 2026 at 20:50, Vishal L. Verma wrote:
> I tried out AI assisted and patch (below) which does happen to solve
> it, but I'm not familiar in this area, and not sure if this is the
> right fix.
>
> diff --git a/include/linux/entry-virt.h b/include/linux/entry-virt.h
> index bfa767702d9a..c4856c252412 100644
> --- a/include/linux/entry-virt.h
> +++ b/include/linux/entry-virt.h
> @@ -4,6 +4,7 @@
>
> #include <linux/static_call_types.h>
> #include <linux/resume_user_mode.h>
> +#include <linux/hrtimer_rearm.h>
> #include <linux/syscalls.h>
> #include <linux/seccomp.h>
> #include <linux/sched.h>
> @@ -58,6 +59,7 @@ int xfer_to_guest_mode_handle_work(void);
> static inline void xfer_to_guest_mode_prepare(void)
> {
> lockdep_assert_irqs_disabled();
> + hrtimer_rearm_deferred();
> tick_nohz_user_enter_prepare();

This code should never be reached with a rearm pending. Something else
went wrong earlier. So while the patch "works" it papers over the
underlying problem.

Can you please do the following:

1) Apply the patch below

2) Enable function tracing and the hrtimer* trace events

3) Enable tracing if it has been disabled already

echo 1 >/sys/kernel/tracing/tracing_on

4) Run the tests and wait for /sys/kernel/tracing/tracing_on to
become 0, which means the problem triggered.

5) Retrieve the trace from /sys/kernel/tracing/trace and provide it
somewhere to download from or send it to me compressed offlist.

Thanks,

tglx
---

diff --git a/include/linux/entry-virt.h b/include/linux/entry-virt.h
index bfa767702d9a..ab73963a7496 100644
--- a/include/linux/entry-virt.h
+++ b/include/linux/entry-virt.h
@@ -58,6 +58,10 @@ int xfer_to_guest_mode_handle_work(void);
static inline void xfer_to_guest_mode_prepare(void)
{
lockdep_assert_irqs_disabled();
+ if (test_thread_flag(TIF_HRTIMER_REARM)) {
+ tracing_off();
+ hrtimer_rearm_deferred();
+ }
tick_nohz_user_enter_prepare();
}