History

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.

Sean Christopherson committed 1 year ago

Commit 0ebac011 parent 7ad8c342 files · +3 −2Browse files

Unified · Split

2 files
  1. drivers/hv/mshv_common.c +1 −1
  2. drivers/hv/mshv_root_main.c +2 −1
drivers/hv/mshv_common.c+1−1
@@ -151,7 +151,7 @@ int mshv_do_pre_guest_mode_work(ulong th_flags) · 150 unmodified lines
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+2−1
@@ -484,7 +484,8 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp) · 483 unmodified lines
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();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t