From: Adrian Hunter <adrian.hunter@intel.com>
To: Ian Rogers <irogers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, namhyung@kernel.org, kan.liang@linux.intel.com,
james.clark@arm.com, tmricht@linux.ibm.com, ak@linux.intel.com,
anshuman.khandual@arm.com, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 2/7] perf evlist: Add evlist__findnew_tracking_event() helper
Date: Mon, 14 Aug 2023 10:40:11 +0300 [thread overview]
Message-ID: <8198296c-7772-1252-16a6-ffa68e86a3f5@intel.com> (raw)
In-Reply-To: <CAP-5=fVmKmgsABpnsngT9L1QeaWaUxakHc1078LahGFqK4-riA@mail.gmail.com>
On 19/07/23 20:12, Ian Rogers wrote:
> On Wed, Jul 19, 2023 at 9:59 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 19/07/23 19:44, Ian Rogers wrote:
>>> On Fri, Jul 14, 2023 at 8:31 PM Yang Jihong <yangjihong1@huawei.com> 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.
>>
>> Except the tracking event has "tracking" set but there can be other dummy
>> events that do not.
>
> Thanks! I'm wondering what a dummy event without tracking would be
> used for - do you have a reference?
For example, text_poke events need to be recorded on all CPUs
because changes to the kernel affect every CPU. Another example.
it can be interesting to capture switch events CPU-wide even if
only some processes are being traced.
> I don't see anything in
> perf_event.h calling things like mmap2/comm in perf_event_attr
> tracking. I'm not a fan of dummy due to it not being intention
> revealing. Perhaps if we could go back in time we could call the
> event "sideband",
Auxiliary events are inband with respect to the perf buffer. Only
when the "main" tracing could be considered to be the AUX area
buffer, can the events in the perf buffer be considered sideband.
> maybe we should migrate to this. We have other
> non-obvious uses of the term dummy like in cpumap:
> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/include/perf/cpumap.h?h=perf-tools-next#n24
> If tracking can be on any event then does that make the functions
> behavior more ambiguous if it means dummy+tracking not <any
> event>+tracking?
>
> Thanks,
> Ian
>
>>>
>>> Thanks,
>>> Ian
>>>
>>>> Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
>>>> ---
>>>> tools/perf/builtin-record.c | 11 +++--------
>>>> tools/perf/util/evlist.c | 18 ++++++++++++++++++
>>>> tools/perf/util/evlist.h | 1 +
>>>> 3 files changed, 22 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>>>> index aec18db7ff23..ca83599cc50c 100644
>>>> --- a/tools/perf/builtin-record.c
>>>> +++ b/tools/perf/builtin-record.c
>>>> @@ -1295,14 +1295,9 @@ static int record__open(struct record *rec)
>>>> */
>>>> if (opts->target.initial_delay || target__has_cpu(&opts->target) ||
>>>> perf_pmus__num_core_pmus() > 1) {
>>>> - pos = evlist__get_tracking_event(evlist);
>>>> - if (!evsel__is_dummy_event(pos)) {
>>>> - /* Set up dummy event. */
>>>> - if (evlist__add_dummy(evlist))
>>>> - return -ENOMEM;
>>>> - pos = evlist__last(evlist);
>>>> - evlist__set_tracking_event(evlist, pos);
>>>> - }
>>>> + pos = evlist__findnew_tracking_event(evlist, false);
>>>> + if (!pos)
>>>> + return -ENOMEM;
>>>>
>>>> /*
>>>> * Enable the dummy event when the process is forked for
>>>> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
>>>> index 7ef43f72098e..25c3ebe2c2f5 100644
>>>> --- a/tools/perf/util/evlist.c
>>>> +++ b/tools/perf/util/evlist.c
>>>> @@ -1694,6 +1694,24 @@ void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_ev
>>>> tracking_evsel->tracking = true;
>>>> }
>>>>
>>>> +struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide)
>>>> +{
>>>> + struct evsel *evsel;
>>>> +
>>>> + evsel = evlist__get_tracking_event(evlist);
>>>> + if (!evsel__is_dummy_event(evsel)) {
>>>> + evsel = evlist__add_aux_dummy(evlist, system_wide);
>>>> + if (!evsel)
>>>> + return NULL;
>>>> +
>>>> + evlist__set_tracking_event(evlist, evsel);
>>>> + } else if (system_wide) {
>>>> + perf_evlist__go_system_wide(&evlist->core, &evsel->core);
>>>> + }
>>>> +
>>>> + return evsel;
>>>> +}
>>>> +
>>>> struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str)
>>>> {
>>>> struct evsel *evsel;
>>>> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
>>>> index 664c6bf7b3e0..98e7ddb2bd30 100644
>>>> --- a/tools/perf/util/evlist.h
>>>> +++ b/tools/perf/util/evlist.h
>>>> @@ -387,6 +387,7 @@ bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr);
>>>>
>>>> struct evsel *evlist__get_tracking_event(struct evlist *evlist);
>>>> void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel);
>>>> +struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide);
>>>>
>>>> struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
>>>>
>>>> --
>>>> 2.30.GIT
>>>>
>>
next prev parent reply other threads:[~2023-08-14 7:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-15 3:29 [PATCH v2 0/7] perf record: Track sideband events for all CPUs when tracing selected CPUs Yang Jihong
2023-07-15 3:29 ` [PATCH v2 1/7] perf evlist: Add perf_evlist__go_system_wide() helper Yang Jihong
2023-07-15 3:29 ` [PATCH v2 2/7] perf evlist: Add evlist__findnew_tracking_event() helper Yang Jihong
2023-07-19 16:44 ` Ian Rogers
2023-07-19 16:59 ` Adrian Hunter
2023-07-19 17:12 ` Ian Rogers
2023-08-14 7:40 ` Adrian Hunter [this message]
2023-07-20 7:23 ` Yang Jihong
2023-07-28 16:40 ` Ian Rogers
2023-07-29 2:10 ` Yang Jihong
2023-07-15 3:29 ` [PATCH v2 3/7] perf record: Move setting dummy tracking before record__init_thread_masks() Yang Jihong
2023-07-15 3:29 ` [PATCH v2 4/7] perf record: Track sideband events for all CPUs when tracing selected CPUs Yang Jihong
2023-07-17 14:25 ` Adrian Hunter
2023-07-18 9:07 ` Yang Jihong
2023-07-15 3:29 ` [PATCH v2 5/7] perf evlist: Skip dummy event sample_type check for evlist_config Yang Jihong
2023-07-17 14:41 ` Adrian Hunter
2023-07-18 9:30 ` Yang Jihong
2023-07-18 9:56 ` Adrian Hunter
2023-07-18 10:17 ` Yang Jihong
2023-07-18 10:29 ` Adrian Hunter
2023-07-18 11:32 ` Yang Jihong
2023-07-20 5:41 ` Adrian Hunter
2023-07-20 7:25 ` Yang Jihong
2023-07-15 3:29 ` [PATCH v2 6/7] perf test: Update system-wide-dummy attr expected values Yang Jihong
2023-07-15 3:29 ` [PATCH v2 7/7] perf test: Add test case for record sideband events Yang Jihong
2023-07-19 16:48 ` Ian Rogers
2023-07-20 7:27 ` Yang Jihong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8198296c-7772-1252-16a6-ffa68e86a3f5@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
--cc=yangjihong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).