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