Update init_psi_monitor to include MEMORY/IO/CPU resources. am: d872253483
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/3050182 Change-Id: I86b3f3c4c1fc7aa4acdeb0fe3afb4797d2f88795 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
1868632e37
|
|
@ -22,9 +22,7 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define PSI_PATH_MEMORY "/proc/pressure/memory"
|
||||
#define PSI_PATH_IO "/proc/pressure/io"
|
||||
#define PSI_PATH_CPU "/proc/pressure/cpu"
|
||||
enum psi_resource { PSI_MEMORY, PSI_IO, PSI_CPU, PSI_RESOURCE_COUNT };
|
||||
|
||||
enum psi_stall_type {
|
||||
PSI_SOME,
|
||||
|
|
@ -45,16 +43,22 @@ struct psi_data {
|
|||
struct psi_stats cpu_stats[PSI_TYPE_COUNT];
|
||||
};
|
||||
|
||||
static const char* psi_resource_file[PSI_RESOURCE_COUNT] = {
|
||||
"/proc/pressure/memory",
|
||||
"/proc/pressure/io",
|
||||
"/proc/pressure/cpu",
|
||||
};
|
||||
|
||||
/*
|
||||
* Initializes psi monitor.
|
||||
* Initializes psi monitor for the given psi resource type.
|
||||
* stall_type, threshold_us and window_us are monitor parameters
|
||||
* When successful, the function returns file descriptor that can
|
||||
* be used with poll/epoll syscalls to wait for EPOLLPRI events.
|
||||
* When unsuccessful, the function returns -1 and errno is set
|
||||
* appropriately.
|
||||
*/
|
||||
int init_psi_monitor(enum psi_stall_type stall_type,
|
||||
int threshold_us, int window_us);
|
||||
int init_psi_monitor(enum psi_stall_type stall_type, int threshold_us, int window_us,
|
||||
enum psi_resource resource = PSI_MEMORY);
|
||||
|
||||
/*
|
||||
* Registers psi monitor file descriptor fd on the epoll instance
|
||||
|
|
|
|||
|
|
@ -33,13 +33,18 @@ static const char* stall_type_name[] = {
|
|||
"full",
|
||||
};
|
||||
|
||||
int init_psi_monitor(enum psi_stall_type stall_type,
|
||||
int threshold_us, int window_us) {
|
||||
int init_psi_monitor(enum psi_stall_type stall_type, int threshold_us, int window_us,
|
||||
enum psi_resource resource) {
|
||||
if (resource < PSI_MEMORY || resource >= PSI_RESOURCE_COUNT) {
|
||||
ALOGE("Invalid psi resource type: %d", resource);
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
int fd;
|
||||
int res;
|
||||
char buf[256];
|
||||
|
||||
fd = TEMP_FAILURE_RETRY(open(PSI_PATH_MEMORY, O_WRONLY | O_CLOEXEC));
|
||||
fd = TEMP_FAILURE_RETRY(open(psi_resource_file[resource], O_WRONLY | O_CLOEXEC));
|
||||
if (fd < 0) {
|
||||
ALOGE("No kernel psi monitor support (errno=%d)", errno);
|
||||
return -1;
|
||||
|
|
@ -58,16 +63,16 @@ int init_psi_monitor(enum psi_stall_type stall_type,
|
|||
}
|
||||
|
||||
if (res >= (ssize_t)sizeof(buf)) {
|
||||
ALOGE("%s line overflow for psi stall type '%s'",
|
||||
PSI_PATH_MEMORY, stall_type_name[stall_type]);
|
||||
ALOGE("%s line overflow for psi stall type '%s'", psi_resource_file[resource],
|
||||
stall_type_name[stall_type]);
|
||||
errno = EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
res = TEMP_FAILURE_RETRY(write(fd, buf, strlen(buf) + 1));
|
||||
if (res < 0) {
|
||||
ALOGE("%s write failed for psi stall type '%s'; errno=%d",
|
||||
PSI_PATH_MEMORY, stall_type_name[stall_type], errno);
|
||||
ALOGE("%s write failed for psi stall type '%s'; errno=%d", psi_resource_file[resource],
|
||||
stall_type_name[stall_type], errno);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
|
|||
6
lmkd.cpp
6
lmkd.cpp
|
|
@ -2035,7 +2035,7 @@ static int psi_parse(struct reread_data *file_data, struct psi_stats stats[], bo
|
|||
|
||||
static int psi_parse_mem(struct psi_data *psi_data) {
|
||||
static struct reread_data file_data = {
|
||||
.filename = PSI_PATH_MEMORY,
|
||||
.filename = psi_resource_file[PSI_MEMORY],
|
||||
.fd = -1,
|
||||
};
|
||||
return psi_parse(&file_data, psi_data->mem_stats, true);
|
||||
|
|
@ -2043,7 +2043,7 @@ static int psi_parse_mem(struct psi_data *psi_data) {
|
|||
|
||||
static int psi_parse_io(struct psi_data *psi_data) {
|
||||
static struct reread_data file_data = {
|
||||
.filename = PSI_PATH_IO,
|
||||
.filename = psi_resource_file[PSI_IO],
|
||||
.fd = -1,
|
||||
};
|
||||
return psi_parse(&file_data, psi_data->io_stats, true);
|
||||
|
|
@ -2051,7 +2051,7 @@ static int psi_parse_io(struct psi_data *psi_data) {
|
|||
|
||||
static int psi_parse_cpu(struct psi_data *psi_data) {
|
||||
static struct reread_data file_data = {
|
||||
.filename = PSI_PATH_CPU,
|
||||
.filename = psi_resource_file[PSI_CPU],
|
||||
.fd = -1,
|
||||
};
|
||||
return psi_parse(&file_data, psi_data->cpu_stats, false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue