Commit f67a7af5 authored by 4ast's avatar 4ast

Merge pull request #551 from vmg/vmg/lua-para

lua: Allow LuaJIT parameterized types in `open_perf_buffer`
parents 9bbe58f9 973a528d
...@@ -254,9 +254,9 @@ function PerfEventArray:_open_perf_buffer(cpu, callback, ctype) ...@@ -254,9 +254,9 @@ function PerfEventArray:_open_perf_buffer(cpu, callback, ctype)
self._callbacks[cpu] = _cb self._callbacks[cpu] = _cb
end end
function PerfEventArray:open_perf_buffer(callback, data_type) function PerfEventArray:open_perf_buffer(callback, data_type, ...)
assert(data_type, "a data type is needed for callback conversion") assert(data_type, "a data type is needed for callback conversion")
local ctype = ffi.typeof(data_type.."*") local ctype = ffi.typeof(data_type.."*", ...)
for i = 0, Posix.cpu_count() - 1 do for i = 0, Posix.cpu_count() - 1 do
self:_open_perf_buffer(i, callback, ctype) self:_open_perf_buffer(i, callback, ctype)
end end
......
...@@ -100,12 +100,8 @@ return function(BPF, utils) ...@@ -100,12 +100,8 @@ return function(BPF, utils)
local TASK_COMM_LEN = 16 -- linux/sched.h local TASK_COMM_LEN = 16 -- linux/sched.h
bpf:get_table("events"):open_perf_buffer(print_event, [[ bpf:get_table("events"):open_perf_buffer(print_event,
struct { "struct { uint64_t stack_id; uint32_t pid; char comm[$]; }",
uint64_t stack_id; TASK_COMM_LEN)
uint32_t pid;
char comm[%d];
}
]] % {TASK_COMM_LEN})
bpf:kprobe_poll_loop() bpf:kprobe_poll_loop()
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment