blob: b825fa53d4984fb087ede482c49db40e6f5cefae [file] [log] [blame]
Johannes Weiner3df0e592018-10-26 15:06:27 -07001#ifndef _LINUX_PSI_H
2#define _LINUX_PSI_H
3
Johannes Weinerc9f51ce2018-11-30 14:09:58 -08004#include <linux/jump_label.h>
Johannes Weiner3df0e592018-10-26 15:06:27 -07005#include <linux/psi_types.h>
6#include <linux/sched.h>
Suren Baghdasaryana163d3f2018-12-03 17:36:42 -08007#include <linux/poll.h>
Suren Baghdasaryanc405bfb2019-02-17 15:07:38 -08008#include <linux/cgroup-defs.h>
Johannes Weiner3df0e592018-10-26 15:06:27 -07009
Johannes Weinere868a992018-10-26 15:06:31 -070010struct seq_file;
11struct css_set;
12
Johannes Weiner3df0e592018-10-26 15:06:27 -070013#ifdef CONFIG_PSI
14
Johannes Weinerc9f51ce2018-11-30 14:09:58 -080015extern struct static_key_false psi_disabled;
Johannes Weiner3df0e592018-10-26 15:06:27 -070016
17void psi_init(void);
18
19void psi_task_change(struct task_struct *task, int clear, int set);
20
21void psi_memstall_tick(struct task_struct *task, int cpu);
22void psi_memstall_enter(unsigned long *flags);
23void psi_memstall_leave(unsigned long *flags);
24
Johannes Weinere868a992018-10-26 15:06:31 -070025int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);
26
27#ifdef CONFIG_CGROUPS
28int psi_cgroup_alloc(struct cgroup *cgrp);
29void psi_cgroup_free(struct cgroup *cgrp);
30void cgroup_move_task(struct task_struct *p, struct css_set *to);
Suren Baghdasaryana163d3f2018-12-03 17:36:42 -080031
32struct psi_trigger *psi_trigger_create(struct psi_group *group,
33 char *buf, size_t nbytes, enum psi_res res);
34void psi_trigger_replace(void **trigger_ptr, struct psi_trigger *t);
35
36unsigned int psi_trigger_poll(void **trigger_ptr, struct file *file,
37 poll_table *wait);
Johannes Weinere868a992018-10-26 15:06:31 -070038#endif
39
Johannes Weiner3df0e592018-10-26 15:06:27 -070040#else /* CONFIG_PSI */
41
42static inline void psi_init(void) {}
43
44static inline void psi_memstall_enter(unsigned long *flags) {}
45static inline void psi_memstall_leave(unsigned long *flags) {}
46
Johannes Weinere868a992018-10-26 15:06:31 -070047#ifdef CONFIG_CGROUPS
48static inline int psi_cgroup_alloc(struct cgroup *cgrp)
49{
50 return 0;
51}
52static inline void psi_cgroup_free(struct cgroup *cgrp)
53{
54}
55static 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 Weiner3df0e592018-10-26 15:06:27 -070061#endif /* CONFIG_PSI */
62
63#endif /* _LINUX_PSI_H */