[RFC PATCH v1 7/9] freezer: raise freeze priority of tasks failed to freeze last time

Zihuan Zhang posted 9 patches 1 month, 4 weeks ago
[RFC PATCH v1 7/9] freezer: raise freeze priority of tasks failed to freeze last time
Posted by Zihuan Zhang 1 month, 4 weeks ago
If there are tasks that fail to freeze in the current suspend attempt,
we raise their freeze priority for the next attempt.

This change ensures that such tasks are frozen earlier in the next
round, helping to reduce retry counts and avoid persistent D-state
tasks due to dependency misordering.

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
 kernel/power/process.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/power/process.c b/kernel/power/process.c
index 21bbca7040cf..9d3cbde905b9 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -111,8 +111,10 @@ static int try_to_freeze_tasks(bool user_only)
 		if (!wakeup || pm_debug_messages_on) {
 			read_lock(&tasklist_lock);
 			for_each_process_thread(g, p) {
-				if (p != current && freezing(p) && !frozen(p))
+				if (p != current && freezing(p) && !frozen(p)) {
+					freeze_set_default_priority(p, FREEZE_PRIORITY_HIGH);
 					sched_show_task(p);
+				}
 			}
 			read_unlock(&tasklist_lock);
 		}
-- 
2.25.1
Re: [RFC PATCH v1 7/9] freezer: raise freeze priority of tasks failed to freeze last time
Posted by Oleg Nesterov 1 month, 3 weeks ago
On 08/07, Zihuan Zhang wrote:
>
> --- a/kernel/power/process.c
> +++ b/kernel/power/process.c
> @@ -111,8 +111,10 @@ static int try_to_freeze_tasks(bool user_only)
>  		if (!wakeup || pm_debug_messages_on) {
>  			read_lock(&tasklist_lock);
>  			for_each_process_thread(g, p) {
> -				if (p != current && freezing(p) && !frozen(p))
> +				if (p != current && freezing(p) && !frozen(p)) {
> +					freeze_set_default_priority(p, FREEZE_PRIORITY_HIGH);
>  					sched_show_task(p);
> +				}

IMO, this change should go into 3/9 to make the intent more clear.

Other than that, I leave this series to maintainers and other reviewers.
Personally, I am skeptical.

Oleg.
Re: [RFC PATCH v1 7/9] freezer: raise freeze priority of tasks failed to freeze last time
Posted by Zihuan Zhang 1 month, 3 weeks ago
在 2025/8/8 22:53, Oleg Nesterov 写道:
>> -				if (p != current && freezing(p) && !frozen(p))
>> +				if (p != current && freezing(p) && !frozen(p)) {
>> +					freeze_set_default_priority(p, FREEZE_PRIORITY_HIGH);
>>   					sched_show_task(p);
>> +				}
> IMO, this change should go into 3/9 to make the intent more clear.
Will do. Indeed, D-state tasks are not easy to solve, so our plan is to 
provide a fallback-like mechanism.
> Other than that, I leave this series to maintainers and other reviewers.
> Personally, I am skeptical.