1 #ifndef _LINUX_PSI_TYPES_H
2 #define _LINUX_PSI_TYPES_H
4 #include <linux/seqlock.h>
5 #include <linux/types.h>
9 /* Tracked task states */
14 NR_PSI_TASK_COUNTS = 3,
17 /* Task state bitmasks */
18 #define TSK_IOWAIT (1 << NR_IOWAIT)
19 #define TSK_MEMSTALL (1 << NR_MEMSTALL)
20 #define TSK_RUNNING (1 << NR_RUNNING)
22 /* Resources that workloads could be stalled on */
31 * Pressure states for each resource:
33 * SOME: Stalled tasks & working tasks
34 * FULL: Stalled tasks & no working tasks
42 /* Only per-CPU, to weigh the CPU in the global average: */
47 struct psi_group_cpu {
48 /* 1st cacheline updated by the scheduler */
50 /* Aggregator needs to know of concurrent changes */
51 seqcount_t seq ____cacheline_aligned_in_smp;
53 /* States of the tasks belonging to this group */
54 unsigned int tasks[NR_PSI_TASK_COUNTS];
56 /* Aggregate pressure state derived from the tasks */
59 /* Period time sampling buckets for each state of interest (ns) */
60 u32 times[NR_PSI_STATES];
62 /* Time of last task change in this group (rq_clock) */
65 /* 2nd cacheline updated by the aggregator */
67 /* Delta detection against the sampling buckets */
68 u32 times_prev[NR_PSI_STATES] ____cacheline_aligned_in_smp;
72 /* Protects data used by the aggregator */
73 struct mutex avgs_lock;
75 /* Per-cpu task state & time tracking */
76 struct psi_group_cpu __percpu *pcpu;
78 /* Running pressure averages */
79 u64 avg_total[NR_PSI_STATES - 1];
82 struct delayed_work avgs_work;
84 /* Total stall times and sampled pressure averages */
85 u64 total[NR_PSI_STATES - 1];
86 unsigned long avg[NR_PSI_STATES - 1][3];
89 #else /* CONFIG_PSI */
93 #endif /* CONFIG_PSI */
95 #endif /* _LINUX_PSI_TYPES_H */