This patch introduces the basic API for setting freeze priority on a per-task basis.
The actual usage and policy for assigning specific priorities will be added in
subsequent patches.
This change lays the groundwork for implementing a more flexible and
dependency-aware freezer model.
Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
include/linux/freezer.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index 6314f8b68035..f231a60c3120 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -46,6 +46,18 @@ static inline bool freezing(struct task_struct *p)
return false;
}
+static inline bool freeze_set_default_priority(struct task_struct *p, unsigned int prio)
+{
+ if ((p->flags & PF_KTHREAD) || prio > FREEZE_PRIORITY_NEVER)
+ return false;
+
+ p->freeze_priority = prio;
+
+ pr_debug("set default freeze priority for comm:%s pid:%d prio:%d\n",
+ p->comm, p->pid, p->freeze_priority);
+ return true;
+}
+
/* Takes and releases task alloc lock using task_lock() */
extern void __thaw_task(struct task_struct *t);
@@ -80,6 +92,7 @@ static inline bool cgroup_freezing(struct task_struct *task)
#else /* !CONFIG_FREEZER */
static inline bool frozen(struct task_struct *p) { return false; }
static inline bool freezing(struct task_struct *p) { return false; }
+static inline bool freeze_set_default_priority(struct task_struct *p, unsigned int prio) {}
static inline void __thaw_task(struct task_struct *t) {}
static inline bool __refrigerator(bool check_kthr_stop) { return false; }
--
2.25.1