阅读一些附加到跟踪点的ebpf示例后,我注意到每个结构都是从这样的填充开始构建的(来自samples/bpf/xdp_redirect_cpu_kern.c)
/* Tracepoint: /sys/kernel/debug/tracing/events/xdp/xdp_cpumap_enqueue/format
* Code in: kernel/include/trace/events/xdp.h
*/
struct cpumap_enqueue_ctx {
u64 __pad; // First 8 bytes are not accessible by bpf code
int map_id; // offset:8; size:4; signed:1;
u32 act; // offset:12; size:4; signed:0;
int cpu; // offset:16; size:4; signed:1;
unsigned int drops; // offset:20; size:4; signed:0;
unsigned int processed; // offset:24; size:4; signed:0;
int to_cpu; // offset:28; size:4; signed:1;
};
Run Code Online (Sandbox Code Playgroud)
我发现的所有评论都是bpf代码无法访问前8个字节,但我不明白为什么。
我按照https://www.kernel.org/doc/Documentation/trace/tracepoints.txt上的教程在内核核心中创建自定义跟踪点(即不在可加载模块中)。
但是,我没有看到perf list或tplist(来自 bcc 工具)的输出中列出的跟踪点。
所以,我不知道如何使用跟踪点。
问题:如何让跟踪点出现在perf list/tplist输出中?
谢谢。