use schedule_timeout_uninterruptible() in nv_sleep_ms() #411
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
nv_sleep_ms() function sets current process to TASK_INTERRUPTIBLE and call schedule_timeout() in a while loop until less than a jiffie remains. It retains in the loop regardless of whether signal is received. What's worse, process in TASK_INTERRUPTIBLE state with pending signal would be set back to TASK_RUNNING in __schedule() function, thus it would be rescheduled again and again, never get into sleep state.
For example, processes calling nv_pci_remove() to remove a device which is still in use would stuck in the sleep-check loop until usage_count down do zero. Once SIGKILL received, it would remain in TASK_RUNNING, leading to a CPU usage at 100%.
Instead, use schedule_timeout_uninterruptible() to substitute the while loop in nv_sleep_ms(). The process would not be woken up only when the requested timeout has expired.
Signed-off-by: huteng.ht [email protected]