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 */
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 /* Period time sampling buckets for each state of interest (ns) */
57 u32 times
[NR_PSI_STATES
];
59 /* Time of last task change in this group (rq_clock) */
62 /* 2nd cacheline updated by the aggregator */
64 /* Delta detection against the sampling buckets */
65 u32 times_prev
[NR_PSI_STATES
] ____cacheline_aligned_in_smp
;
69 /* Protects data updated during an aggregation */
70 struct mutex stat_lock
;
72 /* Per-cpu task state & time tracking */
73 struct psi_group_cpu __percpu
*pcpu
;
75 /* Periodic aggregation state */
76 u64 total_prev
[NR_PSI_STATES
- 1];
79 struct delayed_work clock_work
;
81 /* Total stall times and sampled pressure averages */
82 u64 total
[NR_PSI_STATES
- 1];
83 unsigned long avg
[NR_PSI_STATES
- 1][3];
86 #else /* CONFIG_PSI */
90 #endif /* CONFIG_PSI */
92 #endif /* _LINUX_PSI_TYPES_H */