Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_PSI_H |
| 2 | #define _LINUX_PSI_H |
| 3 | |
Johannes Weiner | c9f51ce | 2018-11-30 14:09:58 -0800 | [diff] [blame] | 4 | #include <linux/jump_label.h> |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 5 | #include <linux/psi_types.h> |
| 6 | #include <linux/sched.h> |
Suren Baghdasaryan | a163d3f | 2018-12-03 17:36:42 -0800 | [diff] [blame] | 7 | #include <linux/poll.h> |
Suren Baghdasaryan | c405bfb | 2019-02-17 15:07:38 -0800 | [diff] [blame] | 8 | #include <linux/cgroup-defs.h> |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 9 | |
Johannes Weiner | e868a99 | 2018-10-26 15:06:31 -0700 | [diff] [blame] | 10 | struct seq_file; |
| 11 | struct css_set; |
| 12 | |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 13 | #ifdef CONFIG_PSI |
| 14 | |
Johannes Weiner | c9f51ce | 2018-11-30 14:09:58 -0800 | [diff] [blame] | 15 | extern struct static_key_false psi_disabled; |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 16 | |
| 17 | void psi_init(void); |
| 18 | |
| 19 | void psi_task_change(struct task_struct *task, int clear, int set); |
| 20 | |
| 21 | void psi_memstall_tick(struct task_struct *task, int cpu); |
| 22 | void psi_memstall_enter(unsigned long *flags); |
| 23 | void psi_memstall_leave(unsigned long *flags); |
| 24 | |
Johannes Weiner | e868a99 | 2018-10-26 15:06:31 -0700 | [diff] [blame] | 25 | int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res); |
| 26 | |
| 27 | #ifdef CONFIG_CGROUPS |
| 28 | int psi_cgroup_alloc(struct cgroup *cgrp); |
| 29 | void psi_cgroup_free(struct cgroup *cgrp); |
| 30 | void cgroup_move_task(struct task_struct *p, struct css_set *to); |
Suren Baghdasaryan | a163d3f | 2018-12-03 17:36:42 -0800 | [diff] [blame] | 31 | |
| 32 | struct psi_trigger *psi_trigger_create(struct psi_group *group, |
| 33 | char *buf, size_t nbytes, enum psi_res res); |
| 34 | void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *t); |
| 35 | |
| 36 | unsigned int psi_trigger_poll(void **trigger_ptr, struct file *file, |
| 37 | poll_table *wait); |
Johannes Weiner | e868a99 | 2018-10-26 15:06:31 -0700 | [diff] [blame] | 38 | #endif |
| 39 | |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 40 | #else /* CONFIG_PSI */ |
| 41 | |
| 42 | static inline void psi_init(void) {} |
| 43 | |
| 44 | static inline void psi_memstall_enter(unsigned long *flags) {} |
| 45 | static inline void psi_memstall_leave(unsigned long *flags) {} |
| 46 | |
Johannes Weiner | e868a99 | 2018-10-26 15:06:31 -0700 | [diff] [blame] | 47 | #ifdef CONFIG_CGROUPS |
| 48 | static inline int psi_cgroup_alloc(struct cgroup *cgrp) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | static inline void psi_cgroup_free(struct cgroup *cgrp) |
| 53 | { |
| 54 | } |
| 55 | static inline void cgroup_move_task(struct task_struct *p, struct css_set *to) |
| 56 | { |
| 57 | rcu_assign_pointer(p->cgroups, to); |
| 58 | } |
| 59 | #endif |
| 60 | |
Johannes Weiner | 3df0e59 | 2018-10-26 15:06:27 -0700 | [diff] [blame] | 61 | #endif /* CONFIG_PSI */ |
| 62 | |
| 63 | #endif /* _LINUX_PSI_H */ |