filter: bytecode already in the list should go before
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 16 Apr 2020 23:44:06 +0000 (19:44 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 17 Apr 2020 13:57:50 +0000 (09:57 -0400)
Background
==========
This `seqnum` (sequence number) feature is currently unused. It was
designed so that the session daemon could tell the tracer the order in
which the bytecode should be run.

Issue
=====
The current implementation of the session daemon doesn't use this
feature so there is only ever a single bytecode to execute per callsite.

During work on an upcoming feature uses this `seqnum` became useful and
it was realized that the current bytecode linking code would reverse the
order in which the bytecode were executed when all bytecodes have the
same `seqnum` value.

This is due to the fact that the `cds_list_for_each_entry_reverse` loops
until it finds a `seqnum` smaller than the new one.

So if all bytecodes have the same `seqnum`, the new bytecode will be
added at the beginning of the list.

This is not technically a problem since it's the session daemon's job to
set the sequence number if it wants a particular ordering. Even
considering that, we found it counterintuitive that new bytecodes are
added at the beginning of the list in those cases.

Solution
========
This commit makes it so that on equality, the insertion is done after
the existing bytecodes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie323b3ff5df346f222e22abfb9bbad6c5b7e4a27

liblttng-ust/lttng-filter.c

index 1967d540bd99b4f9f46f8140042d35e004d10667..bbc212892342f988041b025577de506eeaf0e029 100644 (file)
@@ -536,11 +536,12 @@ void lttng_enabler_event_link_bytecode(struct lttng_event *event,
 
                /*
                 * Insert at specified priority (seqnum) in increasing
-                * order.
+                * order. If there already is a bytecode of the same priority,
+                * insert the new bytecode right after it.
                 */
                cds_list_for_each_entry_reverse(runtime,
                                &event->bytecode_runtime_head, node) {
-                       if (runtime->bc->bc.seqnum < bc->bc.seqnum) {
+                       if (runtime->bc->bc.seqnum <= bc->bc.seqnum) {
                                /* insert here */
                                insert_loc = &runtime->node;
                                goto add_within;
This page took 0.0250010000000001 seconds and 4 git commands to generate.