[DTrace-devel] [PATCH v2 dtrace 0/3] fprobe fallback kprobe support, sched fix

Alan Maguire alan.maguire at oracle.com
Fri Oct 11 10:28:07 UTC 2024


This series is focused on solving a few issues with fprobe-based
attachment which prevent us being able to attach to functions
like finish_task_switch.isra.0.  Such functions are present in
available_filter_functions, but because they either lack BTF
representations or those representations are named without the
.isra suffix, attachment via fentry/fexit is currently impossible.
Falling back to kprobe attach is the best solution here.

As Kris pointed out [1] at compilation time, trampolines have not yet been
set up, so we can replace the provider underlying fbt at that time.
Do so if any fprobes do not have associated BTF (as this will mean they
cannot be attached).

Patch 1 allows tracing of "."-suffixed functions like
finish_task_switch.isra.0.  Patch 2 supports kprobe implementation
fallback when BTF is not present for a to-be-traced fprobe function.
Patch 3 then uses the fact we can now trace "."-suffixed functions
(with kprobe fallback) by using fbt:vmlinux:finish_task_switch*:return
as the kprobe dependent event for on-cpu.

Tested on upstream, 5.15 and 5.4 kernels.

Changes since v1:

- simplified approach by just swapping out probe impl when BTF lookup fails
  (Kris, patch 2)

[1] https://lore.kernel.org/dtrace/20241009140236.883884-1-alan.maguire@oracle.com/

Alan Maguire (3):
  fbt: support "."-suffixed functions for kprobes
  fbt: revert to kprobe impl if we cannot find BTF for fprobe function
  sched: fix on-cpu firing for kernels < 5.16

 libdtrace/dt_bpf.h        |  5 +++++
 libdtrace/dt_prov_fbt.c   | 39 ++++++++++++++++++++++++++++-----------
 libdtrace/dt_prov_sched.c | 23 ++---------------------
 3 files changed, 35 insertions(+), 32 deletions(-)

-- 
2.43.5




More information about the DTrace-devel mailing list