To help diagnose freezing delays caused by tasks stuck in D-state, this
patch adds logging for tasks that are stuck in D-state during each retry
of the freezer loop. Such tasks are not killable and cannot be frozen,
which can cause the system suspend process to retry many times
before aborting. This message can help developers identify which
user-space or kernel tasks are blocking the freeze process.
Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
kernel/power/process.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 87616ca710ac..4007f621c2ad 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -55,6 +55,9 @@ static int try_to_freeze_tasks(bool user_only)
if (p == current || !freeze_task(p))
continue;
+ if (retry > 1 && READ_ONCE(p->__state) == TASK_UNINTERRUPTIBLE)
+ sched_show_task(p);
+
todo++;
}
read_unlock(&tasklist_lock);
--
2.25.1
On Thu, Jun 19, 2025 at 5:54 AM Zihuan Zhang <zhangzihuan@kylinos.cn> wrote: > > To help diagnose freezing delays caused by tasks stuck in D-state, this > patch adds logging for tasks that are stuck in D-state during each retry > of the freezer loop. Such tasks are not killable and cannot be frozen, > which can cause the system suspend process to retry many times > before aborting. This message can help developers identify which > user-space or kernel tasks are blocking the freeze process. > > Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn> > --- > kernel/power/process.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/power/process.c b/kernel/power/process.c > index 87616ca710ac..4007f621c2ad 100644 > --- a/kernel/power/process.c > +++ b/kernel/power/process.c > @@ -55,6 +55,9 @@ static int try_to_freeze_tasks(bool user_only) > if (p == current || !freeze_task(p)) > continue; > > + if (retry > 1 && READ_ONCE(p->__state) == TASK_UNINTERRUPTIBLE) > + sched_show_task(p); > + This is going to be too noisy IMV. Any chance to rate limit it somehow? > todo++; > } > read_unlock(&tasklist_lock); > -- > 2.25.1 >
Hi Rafael, 在 2025/7/3 22:40, Rafael J. Wysocki 写道: > On Thu, Jun 19, 2025 at 5:54 AM Zihuan Zhang <zhangzihuan@kylinos.cn> wrote: >> To help diagnose freezing delays caused by tasks stuck in D-state, this >> patch adds logging for tasks that are stuck in D-state during each retry >> of the freezer loop. Such tasks are not killable and cannot be frozen, >> which can cause the system suspend process to retry many times >> before aborting. This message can help developers identify which >> user-space or kernel tasks are blocking the freeze process. >> >> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn> >> --- >> kernel/power/process.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/kernel/power/process.c b/kernel/power/process.c >> index 87616ca710ac..4007f621c2ad 100644 >> --- a/kernel/power/process.c >> +++ b/kernel/power/process.c >> @@ -55,6 +55,9 @@ static int try_to_freeze_tasks(bool user_only) >> if (p == current || !freeze_task(p)) >> continue; >> >> + if (retry > 1 && READ_ONCE(p->__state) == TASK_UNINTERRUPTIBLE) >> + sched_show_task(p); >> + > This is going to be too noisy IMV. Any chance to rate limit it somehow? Thanks for pointing this out. To avoid excessive verbosity, I’ll make the D-state task logging conditional on pm_debug_messages_on() being true. Additionally, I’ll limit the logging to only occur during retry rounds 1— that should be enough to catch problematic tasks early without spamming the logs in prolonged freeze attempts. + if (pm_debug_messages_on && retry == 1 && READ_ONCE(p->__state) == TASK_UNINTERRUPTIBLE) + sched_show_task(p); + >> todo++; >> } >> read_unlock(&tasklist_lock); >> -- >> 2.25.1 >> Best regards, Zihuan Zhang
© 2016 - 2025 Red Hat, Inc.