From 924f0d2f16a67e7ef83966ab71501b1e73895d8a Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 5 May 2026 16:49:05 -0500 Subject: [PATCH] trace: Only add to annotation array if we're tracing Saves some effort when we're not tracing - but if we start tracing in the middle of creating an annotation it could be missing a couple of fields. Signed-off-by: Derek Foreman --- libweston/weston-trace.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index f19eae457..cf416f2df 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -78,14 +78,16 @@ struct weston_debug_annotation __pd_annots[WESTON_MAX_DEBUG_ANNOTS]; \ unsigned int __pd_i = 0 -#define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ - __pd_i += _Generic((v), \ - int: perfetto_annotate_int, \ - unsigned int: perfetto_annotate_int, \ - float: perfetto_annotate_float, \ - char *: perfetto_annotate_string, \ - const char *: perfetto_annotate_string \ - ) (__pd_annots, __pd_i, k, v); +#define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ + if (unlikely(util_perfetto_is_tracing_enabled())) { \ + __pd_i += _Generic((v), \ + int: perfetto_annotate_int, \ + unsigned int: perfetto_annotate_int, \ + float: perfetto_annotate_float, \ + char *: perfetto_annotate_string, \ + const char *: perfetto_annotate_string \ + ) (__pd_annots, __pd_i, k, v); \ + } #define _WESTON_TRACE_COMMIT_ANNOTATION(id, name) \ do { \