简体   繁体   English

如何将 /kernel/sched/* 包含到 BPF 程序中?

[英]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.

相关问题 如何使用 sched_setaffinity 清除线程关联,这意味着我想将控制权交还给 kernel? - How can I clear thread affinity with sched_setaffinity meaning I want to give control back to the kernel? 如何列出所有已加载到内核的bpf程序? (例如tc-bpf) - How to list all bpf program which is loaded into kernel ? (e.g. tc-bpf) 如何获取 Linux 内核的 bpf_helpers.h 头文件? - How can I get the bpf_helpers.h header file for my Linux kernel? 如何确定BPF_PROG_TYPE_SK_SKB判决程序中数据包的方向? - How can I determine the direction of a packet in a BPF_PROG_TYPE_SK_SKB verdict program? 如何在程序中包含内核头文件 - How to include kernel headers in a program 无法编译示例 bpf 程序,缺少 bpf/bpf.h - Can't compile sample bpf program, bpf/bpf.h is missing 在CFS组计划中,我如何知道sched_entity是叶子的(与实际任务相关联)? - In CFS group schedule, how can I know a sched_entity is a leaf one ( associated with a real task)? BPF:程序上下文的翻译 - BPF: translation of program contexts 使用sched_setaffinity固定到核心后,如何取消固定线程? - How can I unpin a thread after pinning to a core using sched_setaffinity? 如何计算BPF辅助函数的返回码含义? - How can I work out the meaning of the return codes for BPF helper functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM