psi.h 1.6 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4
#ifndef _LINUX_PSI_H
#define _LINUX_PSI_H

5
#include <linux/jump_label.h>
6 7
#include <linux/psi_types.h>
#include <linux/sched.h>
S
Suren Baghdasaryan 已提交
8
#include <linux/poll.h>
9

J
Johannes Weiner 已提交
10 11 12
struct seq_file;
struct css_set;

13 14
#ifdef CONFIG_PSI

15
extern struct static_key_false psi_disabled;
16
extern struct psi_group psi_system;
17 18 19 20

void psi_init(void);

void psi_task_change(struct task_struct *task, int clear, int set);
21 22
void psi_task_switch(struct task_struct *prev, struct task_struct *next,
		     bool sleep);
23 24 25 26

void psi_memstall_enter(unsigned long *flags);
void psi_memstall_leave(unsigned long *flags);

J
Johannes Weiner 已提交
27 28 29 30 31 32
int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res);

#ifdef CONFIG_CGROUPS
int psi_cgroup_alloc(struct cgroup *cgrp);
void psi_cgroup_free(struct cgroup *cgrp);
void cgroup_move_task(struct task_struct *p, struct css_set *to);
S
Suren Baghdasaryan 已提交
33 34 35

struct psi_trigger *psi_trigger_create(struct psi_group *group,
			char *buf, size_t nbytes, enum psi_res res);
36
void psi_trigger_destroy(struct psi_trigger *t);
S
Suren Baghdasaryan 已提交
37 38 39

__poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
			poll_table *wait);
J
Johannes Weiner 已提交
40 41
#endif

42 43 44 45 46 47 48
#else /* CONFIG_PSI */

static inline void psi_init(void) {}

static inline void psi_memstall_enter(unsigned long *flags) {}
static inline void psi_memstall_leave(unsigned long *flags) {}

J
Johannes Weiner 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62
#ifdef CONFIG_CGROUPS
static inline int psi_cgroup_alloc(struct cgroup *cgrp)
{
	return 0;
}
static inline void psi_cgroup_free(struct cgroup *cgrp)
{
}
static inline void cgroup_move_task(struct task_struct *p, struct css_set *to)
{
	rcu_assign_pointer(p->cgroups, to);
}
#endif

63 64 65
#endif /* CONFIG_PSI */

#endif /* _LINUX_PSI_H */