2017-08-25 21:44:52

by Shaohua Li

[permalink] [raw]
Subject: [PATCH] kthread_worker: don't hog the cpu

If the worker thread continues getting work, it will hog the cpu and rcu
stall complains. Make it a good citizen. This is triggered in a loop
block device test.

Signed-off-by: Shaohua Li <[email protected]>
---
kernel/kthread.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 26db528..1c19edf 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -637,6 +637,7 @@ int kthread_worker_fn(void *worker_ptr)
schedule();

try_to_freeze();
+ cond_resched();
goto repeat;
}
EXPORT_SYMBOL_GPL(kthread_worker_fn);
--
2.9.5