From: <qiang.zhang@windriver.com>
To: <ben.dooks@codethink.co.uk>, <bfields@redhat.com>,
<cl@rock-chips.com>, <peterz@infradead.org>, <pmladek@suse.com>,
<tj@kernel.org>
Cc: <akpm@linux-foundation.org>, <naresh.kamboju@linaro.org>,
<mm-commits@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v4] kthread: Work could not be queued when worker being destroyed
Date: Mon, 6 Jul 2020 13:46:47 +0800 [thread overview]
Message-ID: <20200706054647.5344-1-qiang.zhang@windriver.com> (raw)
From: Zhang Qiang <qiang.zhang@windriver.com>
Before the work is put into the queue of the worker thread,
the state of the worker thread needs to be detected,because
the worker thread may be in the destruction state at this time.
Signed-off-by: Zhang Qiang <qiang.zhang@windriver.com>
Suggested-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
v1->v2:
Add warning information for condition "!worker->task".
v2->v3:
Modify submission information and add "Reviewed-by" tags.
v3->v4:
Fix spi controller register trigger Warning.
when a spi controller register, a "kthread_worker_fn" worker is created
through "kthread_run" instead of "kthread_create_worker" which in this
func the "worker->task" will be initialized. and then the "spi_start_queue"
func queue a work to worker queue, at this time, if the worker has not
begin to running, the "!worker->task" will be true, so a warning is triggered.
kernel/kthread.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index bfbfa481be3a..825bd4dcdb95 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -791,6 +791,11 @@ static inline bool queuing_blocked(struct kthread_worker *worker,
{
lockdep_assert_held(&worker->lock);
+ if (kthread_should_stop()) {
+ WARN_ON(1);
+ return true;
+ }
+
return !list_empty(&work->node) || work->canceling;
}
--
2.24.1
next reply other threads:[~2020-07-07 7:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 5:46 qiang.zhang [this message]
2020-07-07 9:06 ` [PATCH v4] kthread: Work could not be queued when worker being destroyed Petr Mladek
2020-07-07 9:32 ` 回复: " Zhang, Qiang
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=20200706054647.5344-1-qiang.zhang@windriver.com \
--to=qiang.zhang@windriver.com \
--cc=akpm@linux-foundation.org \
--cc=ben.dooks@codethink.co.uk \
--cc=bfields@redhat.com \
--cc=cl@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=naresh.kamboju@linaro.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=tj@kernel.org \
/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