From 18d7cb4abbd65b6eb1091d902245271dc49cd8ed Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 29 Aug 2022 16:38:30 -0700 Subject: [PATCH] util/perf: add u_trace_instrument It is called from tracepoints. When it returns false, instrumentation is disabled. Part-of: --- src/gallium/auxiliary/util/u_trace_gallium.c | 2 +- src/util/perf/u_trace.c | 4 ++-- src/util/perf/u_trace.h | 17 +++++++++++------ src/util/perf/u_trace.py | 7 +------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/util/u_trace_gallium.c b/src/gallium/auxiliary/util/u_trace_gallium.c index 419d7e9..ce03470 100644 --- a/src/gallium/auxiliary/util/u_trace_gallium.c +++ b/src/gallium/auxiliary/util/u_trace_gallium.c @@ -76,7 +76,7 @@ u_trace_pipe_context_init(struct u_trace_context *utctx, inline void trace_framebuffer_state(struct u_trace *ut, void *cs, const struct pipe_framebuffer_state *pfb) { - if (likely(!(ut_trace_instrument || ut_perfetto_enabled))) + if (likely(!u_trace_instrument())) return; trace_framebuffer(ut, cs, pfb); diff --git a/src/util/perf/u_trace.c b/src/util/perf/u_trace.c index 116ed9e..2bd80d9 100644 --- a/src/util/perf/u_trace.c +++ b/src/util/perf/u_trace.c @@ -38,7 +38,7 @@ #define TIMESTAMP_BUF_SIZE 0x1000 #define TRACES_PER_CHUNK (TIMESTAMP_BUF_SIZE / sizeof(uint64_t)) -bool ut_trace_instrument; +bool _u_trace_instrument; #ifdef HAVE_PERFETTO int ut_perfetto_enabled; @@ -369,7 +369,7 @@ get_tracefile(void) tracefile = stdout; } - ut_trace_instrument = tracefile || debug_get_option_trace_instrument(); + _u_trace_instrument = tracefile || debug_get_option_trace_instrument(); firsttime = false; } diff --git a/src/util/perf/u_trace.h b/src/util/perf/u_trace.h index b9bfb1d..fcee749 100644 --- a/src/util/perf/u_trace.h +++ b/src/util/perf/u_trace.h @@ -270,12 +270,6 @@ void u_trace_disable_event_range(struct u_trace_iterator begin_it, */ void u_trace_flush(struct u_trace *ut, void *flush_data, bool free_data); -/** - * Whether command buffers should be instrumented even if not collecting - * traces. - */ -extern bool ut_trace_instrument; - #ifdef HAVE_PERFETTO extern int ut_perfetto_enabled; @@ -285,6 +279,17 @@ void u_trace_perfetto_stop(void); # define ut_perfetto_enabled 0 #endif +/** + * Return whether instrumentations should be enabled or not. This is called + * from tracepoints. + */ +static inline bool +u_trace_instrument(void) +{ + extern bool _u_trace_instrument; + return _u_trace_instrument || ut_perfetto_enabled; +} + static inline bool u_trace_context_actively_tracing(struct u_trace_context *utctx) { diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py index d9536fc..9b9fbce 100644 --- a/src/util/perf/u_trace.py +++ b/src/util/perf/u_trace.py @@ -252,13 +252,8 @@ static inline void trace_${trace_name}( , ${arg.type} ${arg.var} % endfor ) { -% if trace.tp_perfetto is not None: - if (!unlikely((ut_trace_instrument || ut_perfetto_enabled) && - ${trace.enabled_expr(trace_toggle_name)})) -% else: - if (!unlikely(ut_trace_instrument && + if (!unlikely(u_trace_instrument() && ${trace.enabled_expr(trace_toggle_name)})) -% endif return; __trace_${trace_name}( ut -- 2.7.4