From 8904bcfacc9114c2260bb1f24d8c9db8df5ebe9e Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 20 Mar 2020 16:23:17 -0400 Subject: [PATCH] Record event as soon as one filter evaluates to TRUE This is a tiny optimization but it can reduce tracing cost in cases where multiple filters are attached to a probe. Since we want to trace an event if any of its filter expressions evaluates to TRUE, there is no need to keep on evaluating expressions once one is found to be TRUE. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: I6b5b7697869d3e25dc24d38dc39c34ae1d49dcc9 --- probes/lttng-tracepoint-event-impl.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h index 321cdfa4..34561243 100644 --- a/probes/lttng-tracepoint-event-impl.h +++ b/probes/lttng-tracepoint-event-impl.h @@ -1171,8 +1171,10 @@ static void __event_probe__##_name(void *__data, _proto) \ tp_locvar, _args); \ lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \ if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \ - __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \ + __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \ __filter_record = 1; \ + break; \ + } \ } \ if (likely(!__filter_record)) \ goto __post; \ @@ -1264,8 +1266,10 @@ static void __event_probe__##_name(void *__data) \ tp_locvar); \ lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \ if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \ - __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \ + __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \ __filter_record = 1; \ + break; \ + } \ } \ if (likely(!__filter_record)) \ goto __post; \ -- 2.34.1