linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] w1: Fix warning on module removal
@ 2022-04-08  3:18 Zheyu Ma
  0 siblings, 0 replies; only message in thread
From: Zheyu Ma @ 2022-04-08  3:18 UTC (permalink / raw)
  To: zbr; +Cc: linux-kernel, Zheyu Ma

This happens because w1_process() can leave the kthread in
TASK_INTERRUPTIBLE state when the kthread is being stopped. Since
kthread_exit() might sleep in exit_signals(), the warning is printed.

Fix this by set the current state to running before exiting.

The following log can reveal it:

[   26.713749] ------------[ cut here ]------------
[   26.714135] do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff83c59b0f>] w1_process+0x22f/0x370
[   26.715053] WARNING: CPU: 4 PID: 282 at kernel/sched/core.c:9660 __might_sleep+0x96/0xb0
[   26.719007] RIP: 0010:__might_sleep+0x96/0xb0
[   26.727411] Call Trace:
[   26.727644]  <TASK>
[   26.727832]  exit_signals+0x2f/0x3b0
[   26.728143]  do_exit+0xcd/0x18c0
[   26.728423]  ? kthread_should_stop+0x5f/0xa0
[   26.728801]  ? w1_process+0x34e/0x370
[   26.729115]  kthread_exit+0x42/0x60
[   26.729407]  ? w1_process_callbacks+0x130/0x130
[   26.729804]  kthread+0x272/0x2e0
[   26.730083]  ? w1_process_callbacks+0x130/0x130
[   26.730464]  ? kthread_blkcg+0xa0/0xa0
[   26.730797]  ret_from_fork+0x22/0x30
[   26.731109]  </TASK>

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/w1/w1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f2ae2e563dc5..ae169f3ee941 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1206,6 +1206,7 @@ int w1_process(void *data)
 			schedule();
 	}
 
+	__set_current_state(TASK_RUNNING);
 	atomic_dec(&dev->refcnt);
 
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-08  3:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08  3:18 [PATCH] w1: Fix warning on module removal Zheyu Ma

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).