mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xuewen Yan <xuewen.yan@unisoc.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <rafael@kernel.org>,
	<pavel@ucw.cz>
Cc: <ke.wang@unisoc.com>, <guohua.yan@unisoc.com>,
	<xuewen.yan94@gmail.com>, <di.shen@unisoc.com>,
	<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH] freezer,sched: Preventing kthreads with D-state from being woken up during freeze
Date: Mon, 17 Jun 2024 14:57:55 +0800	[thread overview]
Message-ID: <20240617065755.9996-1-xuewen.yan@unisoc.com> (raw)

Sometimes althought a kthread was set to be freezable, the thread's
state also could be TASK_UNINTERRUPTIBLE because of some blocked
reasons, such as msleep, wait_for_complete, mutex and so on...
And now, when freezing, the freezer would wakeup them even if
their conditions have not been met, this may not be necessary,
and sometimes waking up early for schedule_timeout() may cause
some driver functions to fail.
So only wake_up kthreads with TASK_INTERRUPTIBLE state.

Co-developed-by: Guohua Yan <guohua.yan@unisoc.com>
Signed-off-by: Guohua Yan <guohua.yan@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 kernel/freezer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/freezer.c b/kernel/freezer.c
index f57aaf96b829..cc50721616a2 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -168,7 +168,7 @@ bool freeze_task(struct task_struct *p)
 	if (!(p->flags & PF_KTHREAD))
 		fake_signal_wake_up(p);
 	else
-		wake_up_state(p, TASK_NORMAL);
+		wake_up_state(p, TASK_INTERRUPTIBLE);
 
 	spin_unlock_irqrestore(&freezer_lock, flags);
 	return true;
-- 
2.25.1


                 reply	other threads:[~2024-06-17  6:59 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=20240617065755.9996-1-xuewen.yan@unisoc.com \
    --to=xuewen.yan@unisoc.com \
    --cc=di.shen@unisoc.com \
    --cc=guohua.yan@unisoc.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=xuewen.yan94@gmail.com \
    /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®