Commit 9c95e4ef authored by Yang Jihong's avatar Yang Jihong Committed by Arnaldo Carvalho de Melo

perf evlist: Add evlist__findnew_tracking_event() helper

Currently, intel-bts, intel-pt, and arm-spe may add tracking event to the
evlist. We may need to search for the tracking event for some settings.

Therefore, add evlist__findnew_tracking_event() helper.

If system_wide is true, evlist__findnew_tracking_event() set the cpu map
of the evsel to all online CPUs.
Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Tested-by: default avatarRavi Bangoria <ravi.bangoria@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20230904023340.12707-3-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f6ff1c76
...@@ -1293,14 +1293,9 @@ static int record__open(struct record *rec) ...@@ -1293,14 +1293,9 @@ static int record__open(struct record *rec)
*/ */
if (opts->target.initial_delay || target__has_cpu(&opts->target) || if (opts->target.initial_delay || target__has_cpu(&opts->target) ||
perf_pmus__num_core_pmus() > 1) { perf_pmus__num_core_pmus() > 1) {
pos = evlist__get_tracking_event(evlist); pos = evlist__findnew_tracking_event(evlist, false);
if (!evsel__is_dummy_event(pos)) { if (!pos)
/* Set up dummy event. */
if (evlist__add_dummy(evlist))
return -ENOMEM; return -ENOMEM;
pos = evlist__last(evlist);
evlist__set_tracking_event(evlist, pos);
}
/* /*
* Enable the dummy event when the process is forked for * Enable the dummy event when the process is forked for
......
...@@ -1694,6 +1694,24 @@ void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_ev ...@@ -1694,6 +1694,24 @@ void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_ev
tracking_evsel->tracking = true; 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 *evlist__find_evsel_by_str(struct evlist *evlist, const char *str)
{ {
struct evsel *evsel; struct evsel *evsel;
......
...@@ -387,6 +387,7 @@ bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr); ...@@ -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); struct evsel *evlist__get_tracking_event(struct evlist *evlist);
void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel); 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); struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment