]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mshv: Handle NEED_RESCHED_LAZY before transferring to guest
authorSean Christopherson <seanjc@google.com>
Thu, 28 Aug 2025 00:01:50 +0000 (17:01 -0700)
committerWei Liu <wei.liu@kernel.org>
Tue, 30 Sep 2025 22:50:18 +0000 (22:50 +0000)
Check for NEED_RESCHED_LAZY, not just NEED_RESCHED, prior to transferring
control to a guest.  Failure to check for lazy resched can unnecessarily
delay rescheduling until the next tick when using a lazy preemption model.

Note, ideally both the checking and processing of TIF bits would be handled
in common code, to avoid having to keep three separate paths synchronized,
but defer such cleanups to the future to keep the fix as standalone as
possible.

Cc: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Cc: Mukesh R <mrathor@linux.microsoft.com>
Fixes: 621191d709b1 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Tested-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/mshv_common.c
drivers/hv/mshv_root_main.c

index 6f227a8a5af719e13dd4601cf03f7eac680fe138..eb3df3e296bbeef73be3df3e5b8cfdcdd2c90c71 100644 (file)
@@ -151,7 +151,7 @@ int mshv_do_pre_guest_mode_work(ulong th_flags)
        if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
                return -EINTR;
 
-       if (th_flags & _TIF_NEED_RESCHED)
+       if (th_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
                schedule();
 
        if (th_flags & _TIF_NOTIFY_RESUME)
index aa20a5c96afaf3ba9a5ad6f182bb2bd8911a516a..3d0d5af80d2ec6128b1aaaf8fe5782ffb705aabd 100644 (file)
@@ -484,7 +484,8 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp)
 static int mshv_pre_guest_mode_work(struct mshv_vp *vp)
 {
        const ulong work_flags = _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING |
-                                _TIF_NEED_RESCHED  | _TIF_NOTIFY_RESUME;
+                                _TIF_NEED_RESCHED  | _TIF_NEED_RESCHED_LAZY |
+                                _TIF_NOTIFY_RESUME;
        ulong th_flags;
 
        th_flags = read_thread_flags();