GNU Linux-libre 5.15.54-gnu
[releases.git] / include / linux / psi.h
1 #ifndef _LINUX_PSI_H
2 #define _LINUX_PSI_H
3
4 #include <linux/jump_label.h>
5 #include <linux/psi_types.h>
6 #include <linux/sched.h>
7 #include <linux/poll.h>
8
9 struct seq_file;
10 struct css_set;
11
12 #ifdef CONFIG_PSI
13
14 extern struct static_key_false psi_disabled;
15 extern struct psi_group psi_system;
16
17 void psi_init(void);
18
19 void psi_task_change(struct task_struct *task, int clear, int set);
20 void psi_task_switch(struct task_struct *prev, struct task_struct *next,
21                      bool sleep);
22
23 void psi_memstall_enter(unsigned long *flags);
24 void psi_memstall_leave(unsigned long *flags);
25
26 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
27 struct psi_trigger *psi_trigger_create(struct psi_group *group,
28                         char *buf, size_t nbytes, enum psi_res res);
29 void psi_trigger_destroy(struct psi_trigger *t);
30
31 __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
32                         poll_table *wait);
33
34 #ifdef CONFIG_CGROUPS
35 int psi_cgroup_alloc(struct cgroup *cgrp);
36 void psi_cgroup_free(struct cgroup *cgrp);
37 void cgroup_move_task(struct task_struct *p, struct css_set *to);
38 #endif
39
40 #else /* CONFIG_PSI */
41
42 static inline void psi_init(void) {}
43
44 static inline void psi_memstall_enter(unsigned long *flags) {}
45 static inline void psi_memstall_leave(unsigned long *flags) {}
46
47 #ifdef CONFIG_CGROUPS
48 static inline int psi_cgroup_alloc(struct cgroup *cgrp)
49 {
50         return 0;
51 }
52 static inline void psi_cgroup_free(struct cgroup *cgrp)
53 {
54 }
55 static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
56 {
57         rcu_assign_pointer(p->cgroups, to);
58 }
59 #endif
60
61 #endif /* CONFIG_PSI */
62
63 #endif /* _LINUX_PSI_H */