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.
Unified · Split
| @@ -151,7 +151,7 @@ int mshv_do_pre_guest_mode_work(ulong th_flags) · 150 unmodified lines | ||
| 151 | 151 | if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) |
| 152 | 152 | return -EINTR; |
| 153 | 153 | |
| 154 | − if (th_flags & _TIF_NEED_RESCHED) | |
| 154 | + if (th_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) | |
| 155 | 155 | schedule(); |
| 156 | 156 | |
| 157 | 157 | if (th_flags & _TIF_NOTIFY_RESUME) |
| @@ -484,7 +484,8 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp) · 483 unmodified lines | ||
| 484 | 484 | static int mshv_pre_guest_mode_work(struct mshv_vp *vp) |
| 485 | 485 | { |
| 486 | 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 | 489 | ulong th_flags; |
| 489 | 490 | |
| 490 | 491 | th_flags = read_thread_flags(); |