Re: [PATCH v2 2/7] perf evlist: Add evlist__findnew_tracking_event() helper

From: Yang Jihong
Date: Fri Jul 28 2023 - 22:11:08 EST


Hello,

On 2023/7/29 0:40, Ian Rogers wrote:
On Thu, Jul 20, 2023 at 12:24 AM Yang Jihong <yangjihong1@xxxxxxxxxx> wrote:

Hello,

On 2023/7/20 0:44, Ian Rogers wrote:
On Fri, Jul 14, 2023 at 8:31 PM Yang Jihong <yangjihong1@xxxxxxxxxx> wrote:

Currently, intel-bts, intel-pt, and arm-spe may add a dummy event for
tracking to the evlist. We may need to search for the dummy event for
some settings. Therefore, add evlist__findnew_tracking_event() helper.

evlist__findnew_tracking_event() also deal with system_wide maps if
system_wide is true.

I'm wondering if we can simplify the naming in the API, we have "dummy
event" which makes sense as we literally call the event "dummy",
"sideband" which refers to the kind of samples/events the dummy event
will record but "tracking" I think tends to get used as a verb rather
than a noun. So I think evlist__findnew_tracking_event should be
evlist__findnew_dummy_event.

Uh, from the discussion that followed, it seems that there is no
consensus yet...
If there is a clear consensus on whether to use "dummy event" or
"tracking event", I will change the name of the API.

I think sideband event is equivalent to tracking event (refer
evsel__config(), tracking events include task, mmap, mmap2, and comm
sideband events, which are all sideband).

tracking event are instances of dummy event. For example, we create
another dummy event to record the text poke event of ksymbol (refer perf
record --kcore).

An evlist contains only one tracking event, but can contain multiple
dummy events.

Thanks for the feedback. So the tracking event is by definition the
first dummy event in the evlist? What is the purpose of the other
Uh... It may not be the first dummy event, but evsel->track must be true. Only one evsel in an evlist meets this condition.

dummy events in this case? Perhaps we can get to an intention
revealing implementation something like:

/** The "tracking event" gathering sideband data is the first dummy
event in the list. */
struct evsel *evlist__findnew_tracking_event(struct evlist *evlist)
{
struct evsel *dummy = evlist__find_first_dummy_event(evlist);

if (!dummy) {
dummy = evlist__add_dummy(evlist);
}
return dummy;
}

But I think the key thing for me is I'm still not sure what is going
on when there are multiple dummy events for you, what are the other
dummy events for other than tracking sideband data?

For other dummy events, perf record will open a dummy event to track ksymbol text_poke when "--kcore" option is used.
I thinks tracking ksymbol text_poke separately it needs to be processed independently, go system_wide and enable immediately.

All of the above is my understanding, may need Adrian to confirm whether it is accurate.

Thanks,
Yang