linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kthread: Use TASK_IDLE state for newly created kernel threads
@ 2020-05-20 11:55 Pavankumar Kondeti
  2020-05-20 18:18 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Pavankumar Kondeti @ 2020-05-20 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vinayak Menon, Pavankumar Kondeti, Greg Kroah-Hartman, Ben Dooks,
	Peter Zijlstra (Intel), Thomas Gleixner, Steven Rostedt (VMware),
	Liang Chen

When kernel threads are created for later use, they will be in
TASK_UNINTERRUPTIBLE state until they are woken up. This results
in increased loadavg and false hung task reports. To fix this,
use TASK_IDLE state instead of TASK_UNINTERRUPTIBLE when
a kernel thread schedules out for the first time.

Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
---
 kernel/kthread.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index bfbfa48..b74ed8e 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -250,7 +250,7 @@ static int kthread(void *_create)
 	current->vfork_done = &self->exited;
 
 	/* OK, tell user we're spawned, wait for stop or wakeup */
-	__set_current_state(TASK_UNINTERRUPTIBLE);
+	__set_current_state(TASK_IDLE);
 	create->result = current;
 	/*
 	 * Thread is going to call schedule(), do not preempt it,
@@ -428,7 +428,7 @@ static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state)
 
 void kthread_bind_mask(struct task_struct *p, const struct cpumask *mask)
 {
-	__kthread_bind_mask(p, mask, TASK_UNINTERRUPTIBLE);
+	__kthread_bind_mask(p, mask, TASK_IDLE);
 }
 
 /**
@@ -442,7 +442,7 @@ void kthread_bind_mask(struct task_struct *p, const struct cpumask *mask)
  */
 void kthread_bind(struct task_struct *p, unsigned int cpu)
 {
-	__kthread_bind(p, cpu, TASK_UNINTERRUPTIBLE);
+	__kthread_bind(p, cpu, TASK_IDLE);
 }
 EXPORT_SYMBOL(kthread_bind);
 
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-21 12:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 11:55 [PATCH] kthread: Use TASK_IDLE state for newly created kernel threads Pavankumar Kondeti
2020-05-20 18:18 ` Greg Kroah-Hartman
2020-05-21  1:35   ` Pavan Kondeti
2020-05-21  5:56     ` Greg Kroah-Hartman
2020-05-21  9:51       ` Pavan Kondeti
2020-05-21 12:03         ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).