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
151 if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))151 if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
152 return -EINTR;152 return -EINTR;
153 153
154 if (th_flags & _TIF_NEED_RESCHED)154 if (th_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
155 schedule();155 schedule();
156 156
157 if (th_flags & _TIF_NOTIFY_RESUME)157 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
484static int mshv_pre_guest_mode_work(struct mshv_vp *vp)484static int mshv_pre_guest_mode_work(struct mshv_vp *vp)
485{485{
486 const ulong work_flags = _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING |486 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;
488 ulong th_flags;489 ulong th_flags;
489 490
490 th_flags = read_thread_flags();491 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