To improve the flexibility and correctness of the freezer subsystem, we introduce a new field `freeze_priority` in `task_struct`. This field will allow us to assign different freezing priorities to tasks, enabling prioritized traversal in future changes. This is particularly useful when dealing with complex inter-process dependencies in modern userspace workloads (e.g., service managers, IPC daemons). Although this patch does not change behavior yet, it provides the necessary infrastructure for upcoming logic to address issues like dependency stalls and D-state hangs. It also helps avoid potential race conditions by paving the way for deterministic freezing order. Signed-off-by: Zihuan Zhang --- include/linux/freezer.h | 7 +++++++ include/linux/sched.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index b303472255be..6314f8b68035 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -16,6 +16,13 @@ DECLARE_STATIC_KEY_FALSE(freezer_active); extern bool pm_freezing; /* PM freezing in effect */ extern bool pm_nosig_freezing; /* PM nosig freezing in effect */ +enum freeze_priority { + FREEZE_PRIORITY_HIGH = 0, + FREEZE_PRIORITY_NORMAL = 1, + FREEZE_PRIORITY_LOW = 2, + FREEZE_PRIORITY_NEVER = 4 +}; + /* * Timeout for stopping processes */ diff --git a/include/linux/sched.h b/include/linux/sched.h index 2b272382673d..7915e6214e50 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -910,6 +910,9 @@ struct task_struct { unsigned int btrace_seq; #endif +#ifdef CONFIG_FREEZER + unsigned int freeze_priority; +#endif unsigned int policy; unsigned long max_allowed_capacity; int nr_cpus_allowed; -- 2.25.1