Skip to content

Commit f76e352

Browse files
captain5050acmel
authored andcommitted
perf parse-events: Pass cpu_list as a perf_cpu_map in __add_event()
Previously the cpu_list is a string and typically no cpu_list is passed to __add_event(). Wanting to make events have their cpus distinct from the PMU means that in more occassions we want to pass a cpu_list. If we're reading this from sysfs it is easier to read a perf_cpu_map than allocate and pass around strings that will later be parsed. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ananth Narayan <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Dhananjay Ugwekar <[email protected]> Cc: Dominique Martinet <[email protected]> Cc: Gautham Shenoy <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sandipan Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent beef8fb commit f76e352

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/perf/util/parse-events.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ __add_event(struct list_head *list, int *idx,
227227
bool init_attr,
228228
const char *name, const char *metric_id, struct perf_pmu *pmu,
229229
struct list_head *config_terms, bool auto_merge_stats,
230-
const char *cpu_list)
230+
struct perf_cpu_map *cpu_list)
231231
{
232232
struct evsel *evsel;
233-
struct perf_cpu_map *cpus = pmu ? perf_cpu_map__get(pmu->cpus) :
234-
cpu_list ? perf_cpu_map__new(cpu_list) : NULL;
233+
struct perf_cpu_map *cpus = perf_cpu_map__is_empty(cpu_list) && pmu ? pmu->cpus : cpu_list;
235234

235+
cpus = perf_cpu_map__get(cpus);
236236
if (pmu)
237237
perf_pmu__warn_invalid_formats(pmu);
238238

@@ -305,16 +305,17 @@ static int add_event_tool(struct list_head *list, int *idx,
305305
.type = PERF_TYPE_SOFTWARE,
306306
.config = PERF_COUNT_SW_DUMMY,
307307
};
308-
const char *cpu_list = NULL;
308+
struct perf_cpu_map *cpu_list = NULL;
309309

310310
if (tool_event == PERF_TOOL_DURATION_TIME) {
311311
/* Duration time is gathered globally, pretend it is only on CPU0. */
312-
cpu_list = "0";
312+
cpu_list = perf_cpu_map__new("0");
313313
}
314314
evsel = __add_event(list, idx, &attr, /*init_attr=*/true, /*name=*/NULL,
315315
/*metric_id=*/NULL, /*pmu=*/NULL,
316316
/*config_terms=*/NULL, /*auto_merge_stats=*/false,
317317
cpu_list);
318+
perf_cpu_map__put(cpu_list);
318319
if (!evsel)
319320
return -ENOMEM;
320321
evsel->tool_event = tool_event;

0 commit comments

Comments
 (0)