xref: /openbmc/linux/include/linux/psi.h (revision aff03707)
12fb75e1bSLiu Xinpeng /* SPDX-License-Identifier: GPL-2.0 */
2eb414681SJohannes Weiner #ifndef _LINUX_PSI_H
3eb414681SJohannes Weiner #define _LINUX_PSI_H
4eb414681SJohannes Weiner 
5e0c27447SJohannes Weiner #include <linux/jump_label.h>
6eb414681SJohannes Weiner #include <linux/psi_types.h>
7eb414681SJohannes Weiner #include <linux/sched.h>
80e94682bSSuren Baghdasaryan #include <linux/poll.h>
93387ce4dSIngo Molnar #include <linux/cgroup-defs.h>
1057899a66SChengming Zhou #include <linux/cgroup.h>
11eb414681SJohannes Weiner 
122ce7135aSJohannes Weiner struct seq_file;
132ce7135aSJohannes Weiner struct css_set;
142ce7135aSJohannes Weiner 
15eb414681SJohannes Weiner #ifdef CONFIG_PSI
16eb414681SJohannes Weiner 
17e0c27447SJohannes Weiner extern struct static_key_false psi_disabled;
18df5ba5beSDan Schatzberg extern struct psi_group psi_system;
19eb414681SJohannes Weiner 
20eb414681SJohannes Weiner void psi_init(void);
21eb414681SJohannes Weiner 
22eb414681SJohannes Weiner void psi_memstall_enter(unsigned long *flags);
23eb414681SJohannes Weiner void psi_memstall_leave(unsigned long *flags);
24eb414681SJohannes Weiner 
252ce7135aSJohannes Weiner int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
26*aff03707SSuren Baghdasaryan struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf,
27*aff03707SSuren Baghdasaryan 				       enum psi_res res, struct file *file,
28*aff03707SSuren Baghdasaryan 				       struct kernfs_open_file *of);
29a06247c6SSuren Baghdasaryan void psi_trigger_destroy(struct psi_trigger *t);
300e94682bSSuren Baghdasaryan 
310e94682bSSuren Baghdasaryan __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
320e94682bSSuren Baghdasaryan 			poll_table *wait);
3351e50fbdSSuren Baghdasaryan 
3451e50fbdSSuren Baghdasaryan #ifdef CONFIG_CGROUPS
cgroup_psi(struct cgroup * cgrp)3557899a66SChengming Zhou static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
3657899a66SChengming Zhou {
3757899a66SChengming Zhou 	return cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi;
3857899a66SChengming Zhou }
3957899a66SChengming Zhou 
4051e50fbdSSuren Baghdasaryan int psi_cgroup_alloc(struct cgroup *cgrp);
4151e50fbdSSuren Baghdasaryan void psi_cgroup_free(struct cgroup *cgrp);
4251e50fbdSSuren Baghdasaryan void cgroup_move_task(struct task_struct *p, struct css_set *to);
4334f26a15SChengming Zhou void psi_cgroup_restart(struct psi_group *group);
442ce7135aSJohannes Weiner #endif
452ce7135aSJohannes Weiner 
46eb414681SJohannes Weiner #else /* CONFIG_PSI */
47eb414681SJohannes Weiner 
psi_init(void)48eb414681SJohannes Weiner static inline void psi_init(void) {}
49eb414681SJohannes Weiner 
psi_memstall_enter(unsigned long * flags)50eb414681SJohannes Weiner static inline void psi_memstall_enter(unsigned long *flags) {}
psi_memstall_leave(unsigned long * flags)51eb414681SJohannes Weiner static inline void psi_memstall_leave(unsigned long *flags) {}
52eb414681SJohannes Weiner 
532ce7135aSJohannes Weiner #ifdef CONFIG_CGROUPS
psi_cgroup_alloc(struct cgroup * cgrp)542ce7135aSJohannes Weiner static inline int psi_cgroup_alloc(struct cgroup *cgrp)
552ce7135aSJohannes Weiner {
562ce7135aSJohannes Weiner 	return 0;
572ce7135aSJohannes Weiner }
psi_cgroup_free(struct cgroup * cgrp)582ce7135aSJohannes Weiner static inline void psi_cgroup_free(struct cgroup *cgrp)
592ce7135aSJohannes Weiner {
602ce7135aSJohannes Weiner }
cgroup_move_task(struct task_struct * p,struct css_set * to)612ce7135aSJohannes Weiner static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
622ce7135aSJohannes Weiner {
632ce7135aSJohannes Weiner 	rcu_assign_pointer(p->cgroups, to);
642ce7135aSJohannes Weiner }
psi_cgroup_restart(struct psi_group * group)6534f26a15SChengming Zhou static inline void psi_cgroup_restart(struct psi_group *group) {}
662ce7135aSJohannes Weiner #endif
672ce7135aSJohannes Weiner 
68eb414681SJohannes Weiner #endif /* CONFIG_PSI */
69eb414681SJohannes Weiner 
70eb414681SJohannes Weiner #endif /* _LINUX_PSI_H */
71