blob: af892c29011664fd17606682349b2000df3fb165 [file] [log] [blame]
Johannes Weinereb414682018-10-26 15:06:27 -07001#ifndef _LINUX_PSI_H
2#define _LINUX_PSI_H
3
Johannes Weinere0c27442018-11-30 14:09:58 -08004#include <linux/jump_label.h>
Johannes Weinereb414682018-10-26 15:06:27 -07005#include <linux/psi_types.h>
6#include <linux/sched.h>
Suren Baghdasaryan0e946822019-05-14 15:41:15 -07007#include <linux/poll.h>
Johannes Weinereb414682018-10-26 15:06:27 -07008
Johannes Weiner2ce71352018-10-26 15:06:31 -07009struct seq_file;
10struct css_set;
11
Johannes Weinereb414682018-10-26 15:06:27 -070012#ifdef CONFIG_PSI
13
Johannes Weinere0c27442018-11-30 14:09:58 -080014extern struct static_key_false psi_disabled;
Johannes Weinereb414682018-10-26 15:06:27 -070015
16void psi_init(void);
17
18void psi_task_change(struct task_struct *task, int clear, int set);
19
20void psi_memstall_tick(struct task_struct *task, int cpu);
21void psi_memstall_enter(unsigned long *flags);
22void psi_memstall_leave(unsigned long *flags);
23
Johannes Weiner2ce71352018-10-26 15:06:31 -070024int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
25
26#ifdef CONFIG_CGROUPS
27int psi_cgroup_alloc(struct cgroup *cgrp);
28void psi_cgroup_free(struct cgroup *cgrp);
29void cgroup_move_task(struct task_struct *p, struct css_set *to);
Suren Baghdasaryan0e946822019-05-14 15:41:15 -070030
31struct psi_trigger *psi_trigger_create(struct psi_group *group,
32 char *buf, size_t nbytes, enum psi_res res);
33void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *t);
34
35__poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
36 poll_table *wait);
Johannes Weiner2ce71352018-10-26 15:06:31 -070037#endif
38
Johannes Weinereb414682018-10-26 15:06:27 -070039#else /* CONFIG_PSI */
40
41static inline void psi_init(void) {}
42
43static inline void psi_memstall_enter(unsigned long *flags) {}
44static inline void psi_memstall_leave(unsigned long *flags) {}
45
Johannes Weiner2ce71352018-10-26 15:06:31 -070046#ifdef CONFIG_CGROUPS
47static inline int psi_cgroup_alloc(struct cgroup *cgrp)
48{
49 return 0;
50}
51static inline void psi_cgroup_free(struct cgroup *cgrp)
52{
53}
54static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
55{
56 rcu_assign_pointer(p->cgroups, to);
57}
58#endif
59
Johannes Weinereb414682018-10-26 15:06:27 -070060#endif /* CONFIG_PSI */
61
62#endif /* _LINUX_PSI_H */