XenevaOS
Loading...
Searching...
No Matches
freezer.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Freezer declarations */
3
4#ifndef FREEZER_H_INCLUDED
5#define FREEZER_H_INCLUDED
6
7#include <linux/debug_locks.h>
8#include <linux/sched.h>
9#include <linux/wait.h>
10#include <linux/atomic.h>
11/*
12 * DCL delta: mainline also includes <linux/jump_label.h> here. DCL drops it.
13 * The static-key machinery is what pulls DEFINE_LOCK_GUARD_0/__PASTE and the
14 * static_branch family in behind it, and none of that is reachable from
15 * virtio_console.c -- its only freezer contact is wait_event_freezable() at
16 * :752 and :784, plus the .freeze callback name, neither of which needs a
17 * jump label. Taking the include out also takes the parse cascade at
18 * jump_label.h:337/:405 out with it, which was what left this file's own
19 * declarations misparsed.
20 */
21
22#ifdef CONFIG_FREEZER
23DECLARE_STATIC_KEY_FALSE(freezer_active);
24
25extern bool pm_freezing; /* PM freezing in effect */
26extern bool pm_nosig_freezing; /* PM nosig freezing in effect */
27
28/*
29 * Timeout for stopping processes
30 */
31extern unsigned int freeze_timeout_msecs;
32
33/*
34 * Check if a process has been frozen for PM or cgroup1 freezer. Note that
35 * cgroup2 freezer uses the job control mechanism and does not interact with
36 * the PM freezer.
37 */
38extern bool frozen(struct task_struct *p);
39
40extern bool freezing_slow_path(struct task_struct *p);
41
42/*
43 * Check if there is a request to freeze a task from PM or cgroup1 freezer.
44 * Note that cgroup2 freezer uses the job control mechanism and does not
45 * interact with the PM freezer.
46 */
47static inline bool freezing(struct task_struct *p)
48{
49 if (static_branch_unlikely(&freezer_active))
50 return freezing_slow_path(p);
51
52 return false;
53}
54
55/* Takes and releases task alloc lock using task_lock() */
56extern void __thaw_task(struct task_struct *t);
57
58extern bool __refrigerator(bool check_kthr_stop);
59extern int freeze_processes(void);
60extern int freeze_kernel_threads(void);
61extern void thaw_processes(void);
62extern void thaw_kernel_threads(void);
63extern void thaw_process(struct task_struct *p);
64
65static inline bool try_to_freeze(void)
66{
68 if (likely(!freezing(current)))
69 return false;
70 if (!(current->flags & PF_NOFREEZE))
71 debug_check_no_locks_held();
72 return __refrigerator(false);
73}
74
75extern bool freeze_task(struct task_struct *p);
76extern bool set_freezable(void);
77
78#ifdef CONFIG_CGROUP_FREEZER
79extern bool cgroup1_freezing(struct task_struct *task);
80#else /* !CONFIG_CGROUP_FREEZER */
81static inline bool cgroup1_freezing(struct task_struct *task)
82{
83 return false;
84}
85#endif /* !CONFIG_CGROUP_FREEZER */
86
87#else /* !CONFIG_FREEZER */
88static inline bool frozen(struct task_struct *p) { return false; }
89static inline bool freezing(struct task_struct *p) { return false; }
90static inline void __thaw_task(struct task_struct *t) {}
91
92static inline bool __refrigerator(bool check_kthr_stop) { return false; }
93static inline int freeze_processes(void) { return -ENOSYS; }
94static inline int freeze_kernel_threads(void) { return -ENOSYS; }
95static inline void thaw_processes(void) {}
96static inline void thaw_kernel_threads(void) {}
97static inline void thaw_process(struct task_struct *p) {}
98
99static inline bool try_to_freeze(void) { return false; }
100
101static inline void set_freezable(void) {}
102
103#endif /* !CONFIG_FREEZER */
104
105#endif /* FREEZER_H_INCLUDED */
XETime t
Definition main.cpp:53
#define likely(x)
Definition compiler.h:29
#define static_branch_unlikely(x)
Definition jump_label.h:501
#define DECLARE_STATIC_KEY_FALSE(name)
Definition jump_label.h:377
#define ENOSYS
Definition kernel.h:310
#define might_sleep()
Definition kernel.h:223
#define current
Definition mm.h:90
Definition sched.h:121