Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eBPF] Fix memory leak when reading lost statistics from perf buffer #6218

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions agent/src/ebpf/user/profile/perf_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,16 @@ static void set_stack_trace_msg(stack_trace_msg_t * msg,
}
}

static void reader_lost_cb_a(void *t, u64 lost)
static void reader_lost_cb_a(void *cookie, u64 lost)
{
struct bpf_tracer *tracer = (struct bpf_tracer *)t;
struct bpf_tracer *tracer = profiler_tracer;
atomic64_add(&tracer->lost, lost);
perf_buf_lost_a_count++;
}

static void reader_lost_cb_b(void *t, u64 lost)
static void reader_lost_cb_b(void *cookie, u64 lost)
{
struct bpf_tracer *tracer = (struct bpf_tracer *)t;
struct bpf_tracer *tracer = profiler_tracer;
atomic64_add(&tracer->lost, lost);
perf_buf_lost_b_count++;
}
Expand Down
5 changes: 3 additions & 2 deletions agent/src/ebpf/user/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,10 @@ static void reader_raw_cb(void *cookie, void *raw, int raw_size)
atomic64_add(&q->enqueue_nr, nr);
}

static void reader_lost_cb(void *t, uint64_t lost)
static void reader_lost_cb(void *cookie, uint64_t lost)
{
struct bpf_tracer *tracer = (struct bpf_tracer *)t;
struct reader_forward_info *fwd_info = cookie;
struct bpf_tracer *tracer = fwd_info->tracer;
atomic64_add(&tracer->lost, lost);
}

Expand Down
1 change: 1 addition & 0 deletions agent/src/ebpf/user/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ static int perf_reader_setup(struct bpf_perf_reader *perf_reader, int thread_nr)

fwd_info->queue_id = spread_id;
fwd_info->cpu_id = i;
fwd_info->tracer = perf_reader->tracer;

ebpf_info("Perf buffer reader cpu(%d) -> queue(%d)\n",
fwd_info->cpu_id, fwd_info->queue_id);
Expand Down
1 change: 1 addition & 0 deletions agent/src/ebpf/user/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ struct bpf_tracer_param_array {
struct reader_forward_info {
uint64_t queue_id;
int cpu_id;
struct bpf_tracer *tracer;
};

extern volatile uint32_t *tracers_lock;
Expand Down
Loading