Remove usage of BPF_FD_JUST_USE_INT in favor of unique_fd

We are trying to remove BPF_FD_JUST_USE_INT since we now have access to
libbase everywhere.

Test: builds
Change-Id: Ie9445d3d648e6837deb718aa38ebef3c936653d6
This commit is contained in:
Patrick Rohr 2024-06-14 14:48:52 -07:00
parent 3641d12083
commit e15214ea24
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;
} }