Panagiotis Papoulidis
Panagiotis Papoulidis

Reputation: 19

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. I tried to include some files from the path linux/kernel/sched/sched.h. How can I include them? (not only the /include folder but also from the linux/kernel/* folder in Linux?)

I'm trying to incorporate #include /kernel/sched/sched.h in order to use "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");
}

Upvotes: 1

Views: 705

Answers (1)

pchaigno
pchaigno

Reputation: 13133

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.

Upvotes: 3

Related Questions