Skip to content

Commit 0ebac01

Browse files
sean-jcliuw
authored andcommitted
mshv: Handle NEED_RESCHED_LAZY before transferring to guest
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: 621191d ("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>
1 parent 7ad8c34 commit 0ebac01

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/hv/mshv_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int mshv_do_pre_guest_mode_work(ulong th_flags)
151151
if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
152152
return -EINTR;
153153

154-
if (th_flags & _TIF_NEED_RESCHED)
154+
if (th_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
155155
schedule();
156156

157157
if (th_flags & _TIF_NOTIFY_RESUME)

drivers/hv/mshv_root_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp)
484484
static int mshv_pre_guest_mode_work(struct mshv_vp *vp)
485485
{
486486
const ulong work_flags = _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING |
487-
_TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME;
487+
_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY |
488+
_TIF_NOTIFY_RESUME;
488489
ulong th_flags;
489490

490491
th_flags = read_thread_flags();

0 commit comments

Comments
 (0)