Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thinktime: Avoid calculating a negative time left to wait
When the thinktime_spin option specifies a value that is within a few milliseconds of the thinktime value, in handle_thinktime() it's possible in a VM environment for the duration of usec_spin() to exceed the thinktime value. While doing usec_spin(), the vCPU could get de-scheduled or the hypervisor could steal CPU time from the vCPU. When the guest vCPU runs after being scheduled again, it may read the clock and find that more time has elapsed than intended. In such a case, the time left to wait could be calculated as a negative value. Subsequent calculations then go awry because the time left is cast as unsigned. Fix this by detecting when the time left would go negative and just set it to zero. Fixes: 1a9bf81 ("Add option to ignore thinktime for rated IO") Fixes: #1588 Link: https://lore.kernel.org/fio/1689354334-131024-1-git-send-email-mikelley@microsoft.com/T/#u Signed-off-by: Michael Kelley <mikelley@microsoft.com> Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
- Loading branch information