Bpftrace: why can't trace kretprobe schedule

Created on 26 Dec 2019  路  3Comments  路  Source: iovisor/bpftrace

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

Most helpful comment

can use tracepoint:sched:sched_switch for schedule out
and use finish_task_switch for schedule back

All 3 comments

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).

https://github.com/iovisor/bpftrace/blob/46e62c0fc2b9d52fccc1af9a366cfe8c9552e694/src/attached_probe.cpp#L560-L561

% 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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fbs picture fbs  路  8Comments

brendangregg picture brendangregg  路  4Comments

paulofelipefeitosa picture paulofelipefeitosa  路  6Comments

Pro-YY picture Pro-YY  路  3Comments

danobi picture danobi  路  8Comments