Merge "Remove usage of BPF_FD_JUST_USE_INT in favor of unique_fd" into main am: 0aeff477af

Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/3133997

Change-Id: I0c20e77d2245d0cf7d1e598ee199b48aa16da276
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2024-07-12 21:14:46 +00:00 committed by Automerger Merge Worker
commit 8e4290acac
1 changed files with 5 additions and 6 deletions

View File

@ -40,6 +40,8 @@
#include <shared_mutex> #include <shared_mutex>
#include <vector> #include <vector>
#include <BpfSyscallWrappers.h>
#include <android-base/unique_fd.h>
#include <bpf/KernelUtils.h> #include <bpf/KernelUtils.h>
#include <bpf/WaitForProgsLoaded.h> #include <bpf/WaitForProgsLoaded.h>
#include <cutils/properties.h> #include <cutils/properties.h>
@ -60,9 +62,6 @@
#include "statslog.h" #include "statslog.h"
#include "watchdog.h" #include "watchdog.h"
#define BPF_FD_JUST_USE_INT
#include "BpfSyscallWrappers.h"
/* /*
* Define LMKD_TRACE_KILLS to record lmkd kills in kernel traces * Define LMKD_TRACE_KILLS to record lmkd kills in kernel traces
* to profile and correlate with OOM kills * to profile and correlate with OOM kills
@ -2116,12 +2115,12 @@ static bool meminfo_parse_line(char *line, union meminfo *mi) {
} }
static int64_t read_gpu_total_kb() { static int64_t read_gpu_total_kb() {
static int fd = android::bpf::bpfFdGet( static android::base::unique_fd fd(
"/sys/fs/bpf/map_gpuMem_gpu_mem_total_map", BPF_F_RDONLY); android::bpf::mapRetrieveRO("/sys/fs/bpf/map_gpuMem_gpu_mem_total_map"));
static constexpr uint64_t kBpfKeyGpuTotalUsage = 0; static constexpr uint64_t kBpfKeyGpuTotalUsage = 0;
uint64_t value; uint64_t value;
if (fd < 0) { if (!fd.ok()) {
return 0; return 0;
} }