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