xref: /openbmc/linux/include/linux/psi.h (revision 519b58bb)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PSI_H
3 #define _LINUX_PSI_H
4 
5 #include <linux/jump_label.h>
6 #include <linux/psi_types.h>
7 #include <linux/sched.h>
8 #include <linux/poll.h>
9 #include <linux/cgroup-defs.h>
10 #include <linux/cgroup.h>
11 
12 struct seq_file;
13 struct css_set;
14 
15 #ifdef CONFIG_PSI
16 
17 extern struct static_key_false psi_disabled;
18 extern struct psi_group psi_system;
19 
20 void psi_init(void);
21 
22 void psi_memstall_enter(unsigned long *flags);
23 void psi_memstall_leave(unsigned long *flags);
24 
25 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
26 struct psi_trigger *psi_trigger_create(struct psi_group *group,
27 			char *buf, enum psi_res res);
28 void psi_trigger_destroy(struct psi_trigger *t);
29 
30 __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
31 			poll_table *wait);
32 
33 #ifdef CONFIG_CGROUPS
34 static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
35 {
36 	return cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi;
37 }
38 
39 int psi_cgroup_alloc(struct cgroup *cgrp);
40 void psi_cgroup_free(struct cgroup *cgrp);
41 void cgroup_move_task(struct task_struct *p, struct css_set *to);
42 void psi_cgroup_restart(struct psi_group *group);
43 #endif
44 
45 #else /* CONFIG_PSI */
46 
47 static inline void psi_init(void) {}
48 
49 static inline void psi_memstall_enter(unsigned long *flags) {}
50 static inline void psi_memstall_leave(unsigned long *flags) {}
51 
52 #ifdef CONFIG_CGROUPS
53 static inline int psi_cgroup_alloc(struct cgroup *cgrp)
54 {
55 	return 0;
56 }
57 static inline void psi_cgroup_free(struct cgroup *cgrp)
58 {
59 }
60 static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
61 {
62 	rcu_assign_pointer(p->cgroups, to);
63 }
64 static inline void psi_cgroup_restart(struct psi_group *group) {}
65 #endif
66 
67 #endif /* CONFIG_PSI */
68 
69 #endif /* _LINUX_PSI_H */
70