Despite the fat comment in utrace_add_engine() I can't really understand
the meaning of ->attaching list.

The comment:

        * When target == current, it would be safe just to call
        * splice_attaching() right here.  But if we're inside a
        * callback,

just to clarify, "inside a callback" means inside utrace_report_xxx(),
not only inside utrace_engine_ops->report_xxx(), right?

                    that would mean the new engine also gets
        * notified about the event that precipitated its own
        * creation.

engine->flags == 0, so it should not be notified until the caller
does utrace_set_events() later, right?

                     This is not what the user wants.

It it not clear to me why the user doesn't want this.

I understand this as follows. If we add the new engine to the ->attached
list, and if the target is inside a callback, the target can later race
with (say) utrace_set_events(). The target can see "engine->flags & event"
and call start_callback/finish_callback before utrace_set_events() completes.

Is this correct?

I guess no. Because the "race" above can happen even if we use ->attaching.
utrace_add_engine() can happen after we already entered utrace_report_xxx(),
but before it does start_report().

Could you clarify?


Another question. In any case I don't understand why do we really need
two lists.

Let's suppose we implement the new trivial helper,

        list_for_each_entry_xxx(pos, head, tail, member)

it stops when "pos" reaches "tail", not "head". Then REPORT_CALLBACKS()
can just read "tail = utrace->attached->prev" (under ->lock, or
utrace_add_engine() can use list_add_rcu) before list_for_each_entry_xxx.

This way we can kill ->attaching, no?

Oleg.

Reply via email to