2

根据 BPF Performance Tools 一书,我正在尝试在 Linux 中使用 bpftrace 制作一个自定义 bpf 程序。我试图从路径 linux/kernel/sched/sched.h 中包含一些文件。我怎样才能包括它们?(不仅是 /include 文件夹,还来自 Linux 中的 linux/kernel/* 文件夹?)

我正在尝试合并#include /kernel/sched/sched.h 以使用“struct rq”。

我的程序示例是:

#!/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");
}
4

1 回答 1

2

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.

This sort of definition copies are already present in bpftrace's examples, for example for struct cfs_rq_partial.

于 2020-04-12T15:29:22.930 回答