mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RFC: siox: don't create a thread without starting it
@ 2018-06-25 10:20 Uwe Kleine-König
  2018-06-25 12:51 ` Peter Zijlstra
  0 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2018-06-25 10:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Oleg Nesterov, Eric W . Biederman,
	Rafael J . Wysocki, Andrew Morton, Gavin Schenk, kernel

On a machine with a siox device I see:

	[  241.130465] INFO: task siox-0:626 blocked for more than 120 seconds.
	[  241.136996]       Not tainted 4.17.0-20180520-1-g6248d1b64190-dirty #8
	[  241.146831] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
	[  241.154868] siox-0          D    0   626      2 0x00000000
	[  241.163241] [<c05f8430>] (__schedule) from [<c05f88ec>] (schedule+0x58/0xc8)
	[  241.172142] [<c05f88ec>] (schedule) from [<c0039098>] (kthread+0xc4/0x140)
	[  241.180899] [<c0039098>] (kthread) from [<c00090e0>] (ret_from_fork+0x14/0x34)
	[  241.188315] Exception stack(0xc72a7fb0 to 0xc72a7ff8)
	[  241.196327] 7fa0:                                     00000000 00000000 00000000 00000000
	[  241.204721] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
	[  241.215861] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000

when I just boot without any other siox-related action. So the kthread (created
in drivers/siox/siox-core.c:siox_master_register()) is never started.

While you could argue that there is little reason to not start the
thread there also is little reason to actually do it.

peterz in #kernelnewbies said "[...] kernel/kthread.c:kthread() should
really be using __set_current_state(TASK_IDLE), I suppose". This however
seems to interfere with problems fixed in a076e4bca2fd ("freezer: fix
kthread_create vs freezer theoretical race").

So I wonder where the real problem is and how it can be fixed.

Explicitly-not-signed-off-for-discussion-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/siox/siox-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index 16590dfaafa4..cef307c0399c 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -715,17 +715,17 @@ int siox_master_register(struct siox_master *smaster)
 
 	dev_set_name(&smaster->dev, "siox-%d", smaster->busno);
 
+	mutex_init(&smaster->lock);
+	INIT_LIST_HEAD(&smaster->devices);
+
 	smaster->last_poll = jiffies;
-	smaster->poll_thread = kthread_create(siox_poll_thread, smaster,
-					      "siox-%d", smaster->busno);
+	smaster->poll_thread = kthread_run(siox_poll_thread, smaster,
+					   "siox-%d", smaster->busno);
 	if (IS_ERR(smaster->poll_thread)) {
 		smaster->active = 0;
 		return PTR_ERR(smaster->poll_thread);
 	}
 
-	mutex_init(&smaster->lock);
-	INIT_LIST_HEAD(&smaster->devices);
-
 	ret = device_add(&smaster->dev);
 	if (ret)
 		kthread_stop(smaster->poll_thread);
-- 
2.17.1


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

end of thread, other threads:[~2018-07-02  6:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25 10:20 [PATCH] RFC: siox: don't create a thread without starting it Uwe Kleine-König
2018-06-25 12:51 ` Peter Zijlstra
2018-06-25 19:21   ` Uwe Kleine-König
2018-06-26  7:31     ` Peter Zijlstra
2018-06-28  7:57       ` [PATCH] " Uwe Kleine-König
2018-06-28  8:18         ` Uwe Kleine-König
2018-06-29  6:27         ` Schenk, Gavin
2018-06-29  7:38         ` Uwe Kleine-König
2018-07-01 23:34           ` Stephen Rothwell
2018-07-02  0:40             ` Stephen Rothwell
2018-07-02  6:49             ` Uwe Kleine-König
2018-06-26  7:37     ` [PATCH] RFC: " Peter Zijlstra
2018-06-26  7:38     ` Peter Zijlstra
2018-06-28  8:03       ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®