[英]How I can include the /kernel/sched/* into a BPF program?
I am trying to make a custom bpf program with bpftrace in Linux, according to the book BPF Performance Tools.根据 BPF Performance Tools 一书,我正在尝试在 Linux 中使用 bpftrace 制作一个自定义 bpf 程序。 I tried to include some files from the path linux/kernel/sched/sched.h.
我试图从路径 linux/kernel/sched/sched.h 中包含一些文件。 How can I include them?
我怎样才能包括它们? (not only the /include folder but also from the linux/kernel/* folder in Linux?)
(不仅是 /include 文件夹,还来自 Linux 中的 linux/kernel/* 文件夹?)
I'm trying to incorporate #include /kernel/sched/sched.h in order to use "struct rq".我正在尝试合并#include /kernel/sched/sched.h 以使用“struct rq”。
The example of my program is:我的程序示例是:
#!/usr/local/bin/bpftrace
#include <kernel/sched/sched.h>
kprobe:load_balance
{
$rq = (struct rq *)arg1;
printf("-------------------\n");
printf("\n");
printf("load_balance: %s pid: %d\n", comm, pid);
printf("-------------------\n");
}
That header isn't exposed, so you'll have to copy the rq
structure definition in your own program if you want to use it or any of its fields. header 没有公开,所以如果你想使用它或它的任何字段,你必须在你自己的程序中复制
rq
结构定义。
This sort of definition copies are already present in bpftrace's examples, for example for struct cfs_rq_partial
.这种定义副本已经存在于 bpftrace 的示例中,例如
struct cfs_rq_partial
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.