mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zheyu Ma <zheyuma97@gmail.com>
To: zbr@ioremap.net
Cc: linux-kernel@vger.kernel.org, Zheyu Ma <zheyuma97@gmail.com>
Subject: [PATCH] w1: Fix warning on module removal
Date: Fri,  8 Apr 2022 11:18:49 +0800	[thread overview]
Message-ID: <20220408031849.897248-1-zheyuma97@gmail.com> (raw)

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


                 reply	other threads:[~2022-04-08  3:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220408031849.897248-1-zheyuma97@gmail.com \
    --to=zheyuma97@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®