Skip to content

Commit

Permalink
Add an override to avoid using --kcore
Browse files Browse the repository at this point in the history
Signed-off-by: Tudor Brindus <[email protected]>
  • Loading branch information
Xyene committed Jun 4, 2024
1 parent 78aa314 commit 42b7c90
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/env_vars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let perf_path = Option.value ~default:"perf" (Unix.getenv "MAGIC_TRACE_PERF_PATH
checks around kernel tracing when not root. *)
let perf_is_privileged = Option.is_some (Unix.getenv "MAGIC_TRACE_PERF_IS_PRIVILEGED")

(** Override whether kcore will be used (in the case that [perf] supports it at all). *)
let perf_no_kcore = Option.is_some (Unix.getenv "MAGIC_TRACE_PERF_NO_KCORE")

(* Turns on hidden command line options and attached "[inferred start time]" to functions
with inferred start times.
Expand Down
1 change: 1 addition & 0 deletions src/env_vars.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ val debug : bool
val experimental : bool
val perf_path : string
val perf_is_privileged : bool
val perf_no_kcore : bool
val perfetto_dir : string option
val no_dlfilter : bool
val fzf_demangle_symbols : bool
41 changes: 23 additions & 18 deletions src/perf_tool_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -319,24 +319,29 @@ module Recording = struct
|> Deferred.return
in
let kcore_opts =
match
collection_mode, trace_scope, Perf_capabilities.(do_intersect capabilities kcore)
with
| Intel_processor_trace _, Userspace, _ | Stacktrace_sampling _, _, _ -> []
| Intel_processor_trace _, (Kernel | Userspace_and_kernel), true -> [ "--kcore" ]
| Intel_processor_trace _, (Kernel | Userspace_and_kernel), false ->
(* Strictly speaking, we could recreate tools/perf/perf-with-kcore.sh
here instead of bailing. But that's tricky, and upgrading to a newer
perf is easier. *)
Core.eprintf
"Warning: old perf version detected! perf userspace tools v5.5 contain an \
important feature, kcore, that make decoding kernel traces more reliable. In \
our experience, tracing the kernel mostly works without this feature, but you \
may run into problems if you're trying to trace through self-modifying code \
(the kernel may do this more than you think). Install a perf version >= 5.5 \
to avoid this.\n\
%!";
[]
if Env_vars.perf_no_kcore
then []
else (
match
( collection_mode
, trace_scope
, Perf_capabilities.(do_intersect capabilities kcore) )
with
| Intel_processor_trace _, Userspace, _ | Stacktrace_sampling _, _, _ -> []
| Intel_processor_trace _, (Kernel | Userspace_and_kernel), true -> [ "--kcore" ]
| Intel_processor_trace _, (Kernel | Userspace_and_kernel), false ->
(* Strictly speaking, we could recreate tools/perf/perf-with-kcore.sh
here instead of bailing. But that's tricky, and upgrading to a newer
perf is easier. *)
Core.eprintf
"Warning: old perf version detected! perf userspace tools v5.5 contain an \
important feature, kcore, that make decoding kernel traces more reliable. \
In our experience, tracing the kernel mostly works without this feature, \
but you may run into problems if you're trying to trace through \
self-modifying code (the kernel may do this more than you think). Install a \
perf version >= 5.5 to avoid this.\n\
%!";
[])
in
let snapshot_size_opt =
match snapshot_size, collection_mode with
Expand Down

0 comments on commit 42b7c90

Please sign in to comment.