[Development report #3] Improve the kinst DTrace provider
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 27 Feb 2023 12:17:16 UTC
I started implementing inline function tracing for kinst by making use of the dt_sugar framework in libdtrace. Contrary to how kinst expects a <function>:<offset> tuple to create probes (e.g vm_fault:4), for inline functions <offset> is replaced by `entry` and `return`. For dt_sugar, `entry` or `return` in a kinst probe mean either of two things: 1) The user requested an entry/return probe but the function is not inline, in which case, the probe will be converted to an FBT one, so that we don't duplicate FBT's functionality in kinst. 2) The function is indeed an inline one, so dt_sugar will find all inline copies of this function and transform D syntax to create new kinst probes for each of them. So if the user requested a entry probe on inline function cam_iosched_has_more_trim_entry(), the resulting D script would look like: # dtrace -dn 'kinst::cam_iosched_has_more_trim:entry' dtrace:::ERROR { ((self->%error) = 0x1); } kinst::cam_iosched_get_trim:13 { } kinst::cam_iosched_next_bio:13 { } kinst::cam_iosched_schedule:40 { } dtrace: description 'kinst::cam_iosched_has_more_trim:entry ' matched 4 probes CPU ID FUNCTION:NAME 0 81502 cam_iosched_schedule:40 0 81501 cam_iosched_next_bio:13 2 81502 cam_iosched_schedule:40 1 81502 cam_iosched_next_bio:13 1 81503 cam_iosched_schedule:40 ^C Currently the code is pretty much a modified version of inlinecall(1)'s code (see previous emails) ported into dt_sugar. Below is the initial commit, it's still a work in progress and there are quite a few bugs (mainly `return` probes) that need fixing: https://github.com/christosmarg/freebsd/commit/bfa507dc22d3856de5af88d0dacaad0f0ab69406 Christos