i use here for trace app schedule out and schedule in, but can't trace schedule in.
uname -r
5.4.1-1.el7.elrepo.x86_64
------------------------
cat 1.c
int main()
{
sleep(1);
return 3;
}
------------------
gcc 1.c
-------------------
./a.out
bpftrace -e 'kprobe:schedule,kretprobe:schedule /comm == "a.out"/{printf("%s\n", probe)}'
Attaching 2 probes...
kprobe:schedule
can use tracepoint:sched:sched_switch for schedule out
and use finish_task_switch for schedule back
Is this because of #835? I observed many nmissed events.
% sudo ./src/bpftrace -e \
'kprobe:unregister_kretprobe {
$rp = (struct kretprobe*)arg0;
printf("nmissed=%d, maxactive=%d\n", $rp->nmissed, $rp->maxactive);
}'
Attaching 1 probe...
nmissed=99, maxactive=2
If I increase maxactive manually (the last argument of bpf_attach_kprobe), kretprobe fired as expected (and no nmissed events).
% sudo ./src/bpftrace -e 'kprobe:schedule,kretprobe:schedule /comm == "a.out"/{printf("%s\n", probe)}'
Attaching 2 probes...
kprobe:schedule
kretprobe:schedule
Perhaps is it nice to introduce BPFTRACE_MAXACTIVE environment variable to control maxactive value?
Most helpful comment
can use tracepoint:sched:sched_switch for schedule out
and use finish_task_switch for schedule back