1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 
6 #include "parse-util.h"
7 #include "time-util.h"
8 
9 typedef enum PressureType {
10         PRESSURE_TYPE_SOME,
11         PRESSURE_TYPE_FULL,
12 } PressureType;
13 
14 /* Averages are stored in fixed-point with 11 bit fractions */
15 typedef struct ResourcePressure {
16         loadavg_t avg10;
17         loadavg_t avg60;
18         loadavg_t avg300;
19         usec_t total;
20 } ResourcePressure;
21 
22 /** Upstream 4.20+ format
23  *
24  *  some avg10=0.22 avg60=0.17 avg300=1.11 total=58761459
25  *  full avg10=0.23 avg60=0.16 avg300=1.08 total=58464525
26  */
27 int read_resource_pressure(const char *path, PressureType type, ResourcePressure *ret);
28 
29 /* Was the kernel compiled with CONFIG_PSI=y? 1 if yes, 0 if not, negative on error. */
30 int is_pressure_supported(void);
31