Skip to content

Commit

Permalink
review comments tranche 1
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey committed May 26, 2024
1 parent 9237959 commit fef0574
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ if(NOT ANDROID)
add_definitions(-DZSTD=1)
endif()

option(usebpf "Enable bpf acceleration")
option(bpf "Enable bpf acceleration")

if(usebpf)
add_definitions(-DUSEBPF=1)
if(bpf)
add_definitions(-DBPF=1)
set(REQUIRED_LIBS
${REQUIRED_LIBS}
libbpf
)
endif(usebpf)
endif(bpf)

foreach(required_lib ${REQUIRED_LIBS})
string(TOUPPER ${required_lib} PKG)
Expand Down Expand Up @@ -701,7 +701,7 @@ post_build_executable(rr)
set(RR_BIN rr)
add_dependencies(rr Generated)

if(usebpf)
if(bpf)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/share/rr/async_event_filter.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/bpf/async_event_filter.c
COMMAND clang -g -target bpf -Wall -O2 -c ${CMAKE_CURRENT_SOURCE_DIR}/src/bpf/async_event_filter.c -o ${CMAKE_CURRENT_BINARY_DIR}/share/rr/async_event_filter.o)
Expand Down
8 changes: 4 additions & 4 deletions src/PerfCounters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <unistd.h>
#include <time.h>

#ifdef USEBPF
#ifdef BPF
#include <bpf/libbpf.h>
#include <linux/hw_breakpoint.h>
#endif
Expand Down Expand Up @@ -1125,7 +1125,7 @@ Ticks PerfCounters::read_ticks(Task* t, Error* error) {
return ret;
}

#ifdef USEBPF
#ifdef BPF
bool PerfCounters::accelerate_async_signal(const Registers& regs) {
static int initialized;
static struct perf_event_attr attr;
Expand Down Expand Up @@ -1158,7 +1158,7 @@ bool PerfCounters::accelerate_async_signal(const Registers& regs) {
if (bpf_object__load(obj) < 0) {
return false;
}
int bpf_map_fd = ScopedFd(bpf_object__find_map_fd_by_name(obj, "registers"));
int bpf_map_fd = bpf_object__find_map_fd_by_name(obj, "registers");
if (bpf_map_fd < 0) {
return false;
}
Expand All @@ -1174,7 +1174,7 @@ bool PerfCounters::accelerate_async_signal(const Registers& regs) {
bpf_regs = (struct user_regs_struct*)
mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, bpf_map_fd, 0);
if (!bpf_regs) {
if (bpf_regs == MAP_FAILED) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/PerfCounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ class PerfCounters {
/**
* Try to use BPF to accelerate async signal processing
*/
#ifdef USEBPF
#ifdef BPF
bool accelerate_async_signal(const Registers& regs);
#else
inline bool accelerate_async_signal(const Registers&) {
bool accelerate_async_signal(const Registers&) {
return false;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/bpf/async_event_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ int match_registers(struct bpf_perf_event_data* event) {
CHECK_REG(rdx)
CHECK_REG(rsi)
CHECK_REG(rdi)
CHECK_REG(rip)
CHECK_REG(rsp)

return 1;
}

char _license[] SEC("license") = "GPL";
char _license[] SEC("license") = "Dual MIT/GPL";

0 comments on commit fef0574

Please sign in to comment.