From: Qingjie Xing <xqjcool@gmail.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org
Cc: dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de,
linux-kernel@vger.kernel.org, Qingjie Xing <xqjcool@gmail.com>
Subject: [PATCH] kernel/sched/wait.c: set timeout to 0 when kthread should stop
Date: Mon, 11 May 2020 23:50:21 -0400 [thread overview]
Message-ID: <1589255421-28264-1-git-send-email-xqjcool@gmail.com> (raw)
Using kthread_stop() to terminate a thread causes tcp_recvmsg()
to enter a dead loop when the kernel thread uses tcp_recvmsg()
to receive a message.
tcp_recvmsg()-->sk_wait_data()-->sk_wait_event()-->wait_woken().
wait_woken() will directly return unchanged timeout value rather
than be executed as normally.
tcp_recvmsg () will continues to execute sk_wait_data(). So finally
this situation will creat an endless loop that cannot be exited.
Signed-off-by: Qingjie Xing <xqjcool@gmail.com>
---
kernel/sched/wait.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index ba059fb..a27bbbd 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -431,6 +431,8 @@ long wait_woken(struct wait_queue_entry *wq_entry, unsigned mode, long timeout)
set_current_state(mode); /* A */
if (!(wq_entry->flags & WQ_FLAG_WOKEN) && !is_kthread_should_stop())
timeout = schedule_timeout(timeout);
+ if (is_kthread_should_stop())
+ timeout = 0;
__set_current_state(TASK_RUNNING);
/*
--
1.8.3.1
reply other threads:[~2020-05-14 6:04 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=1589255421-28264-1-git-send-email-xqjcool@gmail.com \
--to=xqjcool@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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
all inboxes | Powered by JetHome®