Messages in this thread Patch in this message | | | From | Uwe Kleine-König <> | Subject | [PATCH] RFC: siox: don't create a thread without starting it | Date | Mon, 25 Jun 2018 12:20:56 +0200 |
| |
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
| |