Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use schedule_timeout_uninterruptible() in nv_sleep_ms() #411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Hunter1016
Copy link

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]

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant