Add support for syscall::*fork:return tracing in DTrace
Needs ReviewPublic

Authored by gnn on Mar 13 2017, 9:38 AM.

Details

Reviewers
markj
graeme.jenkinson_cl.cam.ac.uk
Group Reviewers
DTrace

Diff Detail

gnn created this revision.Mar 13 2017, 9:38 AM
badger added a subscriber: badger.Mar 13 2017, 12:55 PM

Hmm, if the return is fired here, both parent and child report the same pid (the parent's pid). It would be nice if the child reported its new pid. Why not fire in fork_return() ? One might use td_dbg_sc_code to store which fork variant we should fire the probe for.

It would be more tempting to add the systrace_probe_func invocation at the end of fork_return() where the similar KTRACE probe fires (for similar reasons). Take a look at the call to ktrsysret(SYS_fork, 0, 0); for details.

gnn added a comment.Mar 14 2017, 4:18 AM

Actually it was in kern_fork() that I first looked, but, we do not have access to the syscall args structure at that point. I'll dig a bit more to see if I missed a pointer that would lead me there, or figure out if there is a reasonable way to synthesize one.

markj added a comment.Mar 14 2017, 7:22 PM
In D9987#206482, @gnn wrote:

Actually it was in kern_fork() that I first looked, but, we do not have access to the syscall args structure at that point. I'll dig a bit more to see if I missed a pointer that would lead me there, or figure out if there is a reasonable way to synthesize one.

You might consider adding a special entry point to systrace.c for this purpose. We technically only need sysent[SYS_fork], I think.