[PATCH] kthread_worker: don't hog the cpu

From: Shaohua Li
Date: Fri Aug 25 2017 - 17:44:57 EST


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 <shli@xxxxxx>
---
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