Filter: use only single lower bit of filter return value
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 20 Nov 2012 21:21:18 +0000 (16:21 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Nov 2012 18:56:36 +0000 (13:56 -0500)
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 <dgoulet@efficios.com>
Reviewed-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
liblttng-ust/lttng-filter-interpreter.c
liblttng-ust/lttng-filter.h

index f501fd1459bd6e96356ab52f1a3ddc424447aeb0..331506bd69d838a0c77075489ec3830b859dbe86 100644 (file)
@@ -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 */
 };
index fdecda706b5f0c81a61cc03ace4ba51826015e7d..8f804d62432eace7d5be6fe8811e017e9b524b3c 100644 (file)
@@ -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, \
index e6e96dbff9a9bf53cdb346b68cd63a9b4728d457..690ebde9eece5e1dbb4695e067f014d895bf8a73 100644 (file)
@@ -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;
index 7b7213c988162b20398acb0309b63575d17a47c6..fdc8ac67ed1ada4b72996240de380bf1e6bb3ebb 100644 (file)
@@ -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 */
This page took 0.028351 seconds and 4 git commands to generate.