From: Mathieu Desnoyers Date: Tue, 20 Nov 2012 21:21:18 +0000 (-0500) Subject: Filter: use only single lower bit of filter return value X-Git-Tag: v2.1.0-rc2~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8a92ed2aba5250d41e31d1af5620a2317105c91a;p=lttng-ust.git Filter: use only single lower bit of filter return value Implementation change: use a uint64_t as filter return value, and test with a mask for this bit. This reserves other bits for future use. Reviewed-by: David Goulet Reviewed-by: Christian Babeux Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index f501fd14..331506bd 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -299,10 +299,19 @@ struct lttng_ust_filter_bytecode_node { struct lttng_ust_filter_bytecode bc; }; +/* + * Filter return value masks. + */ +enum lttng_filter_ret { + LTTNG_FILTER_DISCARD = 0, + LTTNG_FILTER_RECORD_FLAG = (1ULL << 0), + /* Other bits are kept for future use. */ +}; + struct lttng_bytecode_runtime { /* Associated bytecode */ struct lttng_ust_filter_bytecode_node *bc; - int (*filter)(void *filter_data, const char *filter_stack_data); + uint64_t (*filter)(void *filter_data, const char *filter_stack_data); int link_failed; struct cds_list_head node; /* list of bytecode runtime in event */ }; diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index fdecda70..8f804d62 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -489,16 +489,16 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \ return; \ if (caa_unlikely(!cds_list_empty(&__event->bytecode_runtime_head))) { \ struct lttng_bytecode_runtime *bc_runtime; \ - int __filter_result = 0; \ + int __filter_record = 0; \ \ __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \ _TP_ARGS_DATA_VAR(_args)); \ cds_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \ if (caa_unlikely(bc_runtime->filter(bc_runtime, \ - __stackvar.__filter_stack_data))) \ - __filter_result = 1; \ + __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \ + __filter_record = 1; \ } \ - if (caa_likely(!__filter_result)) \ + if (caa_likely(!__filter_record)) \ return; \ } \ __event_len = __event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \ diff --git a/liblttng-ust/lttng-filter-interpreter.c b/liblttng-ust/lttng-filter-interpreter.c index e6e96dbf..690ebde9 100644 --- a/liblttng-ust/lttng-filter-interpreter.c +++ b/liblttng-ust/lttng-filter-interpreter.c @@ -105,7 +105,7 @@ int stack_strcmp(struct estack *stack, int top, const char *cmp_type) return diff; } -int lttng_filter_false(void *filter_data, +uint64_t lttng_filter_false(void *filter_data, const char *filter_stack_data) { return 0; @@ -157,7 +157,12 @@ LABEL_##name #endif -int lttng_filter_interpret_bytecode(void *filter_data, +/* + * Return 0 (discard), or raise the 0x1 flag (log event). + * Currently, other flags are kept for future extensions and have no + * effect. + */ +uint64_t lttng_filter_interpret_bytecode(void *filter_data, const char *filter_stack_data) { struct bytecode_runtime *bytecode = filter_data; @@ -279,6 +284,7 @@ int lttng_filter_interpret_bytecode(void *filter_data, goto end; OP(FILTER_OP_RETURN): + /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */ retval = !!estack_ax_v; ret = 0; goto end; diff --git a/liblttng-ust/lttng-filter.h b/liblttng-ust/lttng-filter.h index 7b7213c9..fdc8ac67 100644 --- a/liblttng-ust/lttng-filter.h +++ b/liblttng-ust/lttng-filter.h @@ -190,9 +190,9 @@ const char *print_op(enum filter_op op); int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode); int lttng_filter_specialize_bytecode(struct bytecode_runtime *bytecode); -int lttng_filter_false(void *filter_data, +uint64_t lttng_filter_false(void *filter_data, const char *filter_stack_data); -int lttng_filter_interpret_bytecode(void *filter_data, +uint64_t lttng_filter_interpret_bytecode(void *filter_data, const char *filter_stack_data); #endif /* _LTTNG_FILTER_H */