From 8fd066b0a35ea1fa9414c87a1d10fdbb3285eef7 Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Fri, 22 Nov 2024 09:34:14 -0800 Subject: [PATCH] Short circut printk if tracing is not enabled (#4035) Signed-off-by: Alan Jowett Co-authored-by: Alan Jowett --- libs/execution_context/ebpf_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/execution_context/ebpf_core.c b/libs/execution_context/ebpf_core.c index 59d127086e..d30247d820 100644 --- a/libs/execution_context/ebpf_core.c +++ b/libs/execution_context/ebpf_core.c @@ -2321,6 +2321,11 @@ _ebpf_core_trace_printk(_In_reads_(fmt_size) const char* fmt, size_t fmt_size, i return -1; } + // If the provider is not enabled, don't bother with the rest. + if (!TraceLoggingProviderEnabled(ebpf_tracelog_provider, EBPF_TRACELOG_LEVEL_INFO, EBPF_TRACELOG_KEYWORD_PRINTK)) { + return 0; + } + // Make a copy of the original format string. char* output = (char*)ebpf_allocate_with_tag(fmt_size + 1, EBPF_POOL_TAG_CORE); if (output == NULL) {