Skip to content

Commit

Permalink
Add cb_cookie to perf_reader_lost_cb
Browse files Browse the repository at this point in the history
  • Loading branch information
palmtenor committed Dec 20, 2017
1 parent d271f3e commit b7bbd04
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cc/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int bpf_open_raw_sock(const char *name);
typedef void (*perf_reader_cb)(void *cb_cookie, int pid, uint64_t callchain_num,
void *callchain);
typedef void (*perf_reader_raw_cb)(void *cb_cookie, void *raw, int raw_size);
typedef void (*perf_reader_lost_cb)(uint64_t lost);
typedef void (*perf_reader_lost_cb)(void *cb_cookie, uint64_t lost);

void *bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type,
const char *ev_name, const char *fn_name,
Expand Down
2 changes: 1 addition & 1 deletion src/cc/perf_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void perf_reader_event_read(struct perf_reader *reader) {
*/
uint64_t lost = *(uint64_t *)(ptr + sizeof(*e) + sizeof(uint64_t));
if (reader->lost_cb) {
reader->lost_cb(lost);
reader->lost_cb(reader->cb_cookie, lost);
} else {
fprintf(stderr, "Possibly lost %" PRIu64 " samples\n", lost);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lua/bcc/libbcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int bpf_open_raw_sock(const char *name);

typedef void (*perf_reader_cb)(void *cb_cookie, int pid, uint64_t callchain_num, void *callchain);
typedef void (*perf_reader_raw_cb)(void *cb_cookie, void *raw, int raw_size);
typedef void (*perf_reader_lost_cb)(uint64_t lost);
typedef void (*perf_reader_lost_cb)(void *cb_cookie, uint64_t lost);

void *bpf_attach_kprobe(int progfd, int attach_type, const char *ev_name,
const char *fn_name, perf_reader_cb cb,
Expand Down
4 changes: 2 additions & 2 deletions src/lua/bcc/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ function PerfEventArray:_open_perf_buffer(cpu, callback, ctype, page_cnt, lost_c
local _lost_cb = nil
if lost_cb then
_lost_cb = ffi.cast("perf_reader_lost_cb",
function (lost)
lost_cb(lost)
function (cookie, lost)
lost_cb(cookie, lost)
end)
end

Expand Down
2 changes: 1 addition & 1 deletion src/python/bcc/libbcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_int,
ct.c_ulonglong, ct.POINTER(ct.c_ulonglong))
_RAW_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_void_p, ct.c_int)
_LOST_CB_TYPE = ct.CFUNCTYPE(None, ct.c_ulonglong)
_LOST_CB_TYPE = ct.CFUNCTYPE(None, ct.py_object, ct.c_ulonglong)
lib.bpf_attach_kprobe.argtypes = [ct.c_int, ct.c_int, ct.c_char_p, ct.c_char_p,
_CB_TYPE, ct.py_object]
lib.bpf_detach_kprobe.restype = ct.c_int
Expand Down

0 comments on commit b7bbd04

Please sign in to comment.