Merge "lmkd: Include total GPU memory usage in killinfo reports" am: cde0acde94 am: e0d6203d39 am: 740eb4cb91
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1721873 Change-Id: Ica28e8907c4d9907eaa4cd12c32549a8540939d0
This commit is contained in:
commit
97fb31c8f7
|
|
@ -23,6 +23,9 @@ cc_binary {
|
|||
"libstatslogc",
|
||||
"liblmkd_utils",
|
||||
],
|
||||
header_libs: [
|
||||
"bpf_syscall_wrappers",
|
||||
],
|
||||
local_include_dirs: ["include"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
|
|
|
|||
|
|
@ -35,4 +35,4 @@
|
|||
# TODO: generate ".java" and ".h" files with integer constants from this file.
|
||||
|
||||
# for killinfo logs
|
||||
10195355 killinfo (Pid|1|5),(Uid|1|5),(OomAdj|1),(MinOomAdj|1),(TaskSize|1),(enum kill_reasons|1|5),(MemFree|1),(Cached|1),(SwapCached|1),(Buffers|1),(Shmem|1),(Unevictable|1),(SwapTotal|1),(SwapFree|1),(ActiveAnon|1),(InactiveAnon|1),(ActiveFile|1),(InactiveFile|1),(SReclaimable|1),(SUnreclaim|1),(KernelStack|1),(PageTables|1),(IonHeap|1),(IonHeapPool|1),(CmaFree|1),(MsSinceEvent|1),(MsSincePrevWakeup|1),(WakeupsSinceEvent|1),(SkippedWakeups|1),(TaskSwapSize|1)
|
||||
10195355 killinfo (Pid|1|5),(Uid|1|5),(OomAdj|1),(MinOomAdj|1),(TaskSize|1),(enum kill_reasons|1|5),(MemFree|1),(Cached|1),(SwapCached|1),(Buffers|1),(Shmem|1),(Unevictable|1),(SwapTotal|1),(SwapFree|1),(ActiveAnon|1),(InactiveAnon|1),(ActiveFile|1),(InactiveFile|1),(SReclaimable|1),(SUnreclaim|1),(KernelStack|1),(PageTables|1),(IonHeap|1),(IonHeapPool|1),(CmaFree|1),(MsSinceEvent|1),(MsSincePrevWakeup|1),(WakeupsSinceEvent|1),(SkippedWakeups|1),(TaskSwapSize|1),(GPU|1)
|
||||
|
|
|
|||
21
lmkd.cpp
21
lmkd.cpp
|
|
@ -53,6 +53,9 @@
|
|||
|
||||
#include "statslog.h"
|
||||
|
||||
#define BPF_FD_JUST_USE_INT
|
||||
#include "BpfSyscallWrappers.h"
|
||||
|
||||
/*
|
||||
* Define LMKD_TRACE_KILLS to record lmkd kills in kernel traces
|
||||
* to profile and correlate with OOM kills
|
||||
|
|
@ -431,6 +434,7 @@ union meminfo {
|
|||
int64_t cma_free;
|
||||
/* fields below are calculated rather than read from the file */
|
||||
int64_t nr_file_pages;
|
||||
int64_t total_gpu_kb;
|
||||
} field;
|
||||
int64_t arr[MI_FIELD_COUNT];
|
||||
};
|
||||
|
|
@ -1785,6 +1789,21 @@ static bool meminfo_parse_line(char *line, union meminfo *mi) {
|
|||
return (match_res != PARSE_FAIL);
|
||||
}
|
||||
|
||||
static int64_t read_gpu_total_kb() {
|
||||
static int fd = android::bpf::bpfFdGet(
|
||||
"/sys/fs/bpf/map_gpu_mem_gpu_mem_total_map", BPF_F_RDONLY);
|
||||
static constexpr uint64_t kBpfKeyGpuTotalUsage = 0;
|
||||
uint64_t value;
|
||||
|
||||
if (fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return android::bpf::findMapEntry(fd, &kBpfKeyGpuTotalUsage, &value)
|
||||
? 0
|
||||
: (int32_t)(value / 1024);
|
||||
}
|
||||
|
||||
static int meminfo_parse(union meminfo *mi) {
|
||||
static struct reread_data file_data = {
|
||||
.filename = MEMINFO_PATH,
|
||||
|
|
@ -1809,6 +1828,7 @@ static int meminfo_parse(union meminfo *mi) {
|
|||
}
|
||||
mi->field.nr_file_pages = mi->field.cached + mi->field.swap_cached +
|
||||
mi->field.buffers;
|
||||
mi->field.total_gpu_kb = read_gpu_total_kb();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1923,6 +1943,7 @@ static void killinfo_log(struct proc* procp, int min_oom_score, int rss_kb,
|
|||
android_log_write_int32(ctx, wi->wakeups_since_event);
|
||||
android_log_write_int32(ctx, wi->skipped_wakeups);
|
||||
android_log_write_int32(ctx, (int32_t)min(swap_kb, INT32_MAX));
|
||||
android_log_write_int32(ctx, (int32_t)mi->field.total_gpu_kb);
|
||||
|
||||
android_log_write_list(ctx, LOG_ID_EVENTS);
|
||||
android_log_reset(ctx);
|
||||
|
|
|
|||
Loading…
Reference in New Issue