xref: /linux-6.15/include/linux/psi.h (revision d79ddb06)
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_memstall_enter(unsigned long *flags);
22 void psi_memstall_leave(unsigned long *flags);
23 
24 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
25 struct psi_trigger *psi_trigger_create(struct psi_group *group,
26 			char *buf, enum psi_res res);
27 void psi_trigger_destroy(struct psi_trigger *t);
28 
29 __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
30 			poll_table *wait);
31 
32 #ifdef CONFIG_CGROUPS
33 int psi_cgroup_alloc(struct cgroup *cgrp);
34 void psi_cgroup_free(struct cgroup *cgrp);
35 void cgroup_move_task(struct task_struct *p, struct css_set *to);
36 #endif
37 
38 #else /* CONFIG_PSI */
39 
40 static inline void psi_init(void) {}
41 
42 static inline void psi_memstall_enter(unsigned long *flags) {}
43 static inline void psi_memstall_leave(unsigned long *flags) {}
44 
45 #ifdef CONFIG_CGROUPS
46 static inline int psi_cgroup_alloc(struct cgroup *cgrp)
47 {
48 	return 0;
49 }
50 static inline void psi_cgroup_free(struct cgroup *cgrp)
51 {
52 }
53 static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
54 {
55 	rcu_assign_pointer(p->cgroups, to);
56 }
57 #endif
58 
59 #endif /* CONFIG_PSI */
60 
61 #endif /* _LINUX_PSI_H */
62