Commit fe1f61b3 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

libperf: Add own_cpus to struct perf_evsel

Move own_cpus from tools/perf's evsel to libbpf's perf_evsel.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-52-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d400bd3a
...@@ -11,6 +11,7 @@ struct perf_evsel { ...@@ -11,6 +11,7 @@ struct perf_evsel {
struct list_head node; struct list_head node;
struct perf_event_attr attr; struct perf_event_attr attr;
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
struct perf_cpu_map *own_cpus;
}; };
#endif /* __LIBPERF_INTERNAL_EVSEL_H */ #endif /* __LIBPERF_INTERNAL_EVSEL_H */
...@@ -109,11 +109,11 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu ...@@ -109,11 +109,11 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
TEST_ASSERT_VAL("failed to synthesize attr update name", TEST_ASSERT_VAL("failed to synthesize attr update name",
!perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name)); !perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name));
evsel->own_cpus = perf_cpu_map__new("1,2,3"); evsel->core.own_cpus = perf_cpu_map__new("1,2,3");
TEST_ASSERT_VAL("failed to synthesize attr update cpus", TEST_ASSERT_VAL("failed to synthesize attr update cpus",
!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus)); !perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
perf_cpu_map__put(evsel->own_cpus); perf_cpu_map__put(evsel->core.own_cpus);
return 0; return 0;
} }
...@@ -159,12 +159,12 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, ...@@ -159,12 +159,12 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
* We already have cpus for evsel (via PMU sysfs) so * We already have cpus for evsel (via PMU sysfs) so
* keep it, if there's no target cpu list defined. * keep it, if there's no target cpu list defined.
*/ */
if (!evsel->own_cpus || evlist->has_user_cpus) { if (!evsel->core.own_cpus || evlist->has_user_cpus) {
perf_cpu_map__put(evsel->core.cpus); perf_cpu_map__put(evsel->core.cpus);
evsel->core.cpus = perf_cpu_map__get(evlist->cpus); evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
} else if (evsel->core.cpus != evsel->own_cpus) { } else if (evsel->core.cpus != evsel->core.own_cpus) {
perf_cpu_map__put(evsel->core.cpus); perf_cpu_map__put(evsel->core.cpus);
evsel->core.cpus = perf_cpu_map__get(evsel->own_cpus); evsel->core.cpus = perf_cpu_map__get(evsel->core.own_cpus);
} }
perf_thread_map__put(evsel->threads); perf_thread_map__put(evsel->threads);
......
...@@ -1125,7 +1125,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, ...@@ -1125,7 +1125,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
attr->exclude_user = 1; attr->exclude_user = 1;
} }
if (evsel->own_cpus || evsel->unit) if (evsel->core.own_cpus || evsel->unit)
evsel->core.attr.read_format |= PERF_FORMAT_ID; evsel->core.attr.read_format |= PERF_FORMAT_ID;
/* /*
...@@ -1326,7 +1326,7 @@ void perf_evsel__exit(struct evsel *evsel) ...@@ -1326,7 +1326,7 @@ void perf_evsel__exit(struct evsel *evsel)
perf_evsel__free_config_terms(evsel); perf_evsel__free_config_terms(evsel);
cgroup__put(evsel->cgrp); cgroup__put(evsel->cgrp);
perf_cpu_map__put(evsel->core.cpus); perf_cpu_map__put(evsel->core.cpus);
perf_cpu_map__put(evsel->own_cpus); perf_cpu_map__put(evsel->core.own_cpus);
perf_thread_map__put(evsel->threads); perf_thread_map__put(evsel->threads);
zfree(&evsel->group_name); zfree(&evsel->group_name);
zfree(&evsel->name); zfree(&evsel->name);
......
...@@ -123,7 +123,6 @@ struct evsel { ...@@ -123,7 +123,6 @@ struct evsel {
u64 db_id; u64 db_id;
struct cgroup *cgrp; struct cgroup *cgrp;
void *handler; void *handler;
struct perf_cpu_map *own_cpus;
struct perf_thread_map *threads; struct perf_thread_map *threads;
unsigned int sample_size; unsigned int sample_size;
int id_pos; int id_pos;
......
...@@ -3861,10 +3861,10 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool, ...@@ -3861,10 +3861,10 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
int max, err; int max, err;
u16 type; u16 type;
if (!evsel->own_cpus) if (!evsel->core.own_cpus)
return 0; return 0;
ev = cpu_map_data__alloc(evsel->own_cpus, &size, &type, &max); ev = cpu_map_data__alloc(evsel->core.own_cpus, &size, &type, &max);
if (!ev) if (!ev)
return -ENOMEM; return -ENOMEM;
...@@ -3874,7 +3874,7 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool, ...@@ -3874,7 +3874,7 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
ev->id = evsel->id[0]; ev->id = evsel->id[0];
cpu_map_data__synthesize((struct cpu_map_data *) ev->data, cpu_map_data__synthesize((struct cpu_map_data *) ev->data,
evsel->own_cpus, evsel->core.own_cpus,
type, max); type, max);
err = process(tool, (union perf_event*) ev, NULL, NULL); err = process(tool, (union perf_event*) ev, NULL, NULL);
...@@ -3985,7 +3985,7 @@ int perf_event__synthesize_extra_attr(struct perf_tool *tool, ...@@ -3985,7 +3985,7 @@ int perf_event__synthesize_extra_attr(struct perf_tool *tool,
} }
} }
if (counter->own_cpus) { if (counter->core.own_cpus) {
err = perf_event__synthesize_event_update_cpus(tool, counter, process); err = perf_event__synthesize_event_update_cpus(tool, counter, process);
if (err < 0) { if (err < 0) {
pr_err("Couldn't synthesize evsel cpus.\n"); pr_err("Couldn't synthesize evsel cpus.\n");
...@@ -4082,7 +4082,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, ...@@ -4082,7 +4082,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
map = cpu_map__new_data(&ev_cpus->cpus); map = cpu_map__new_data(&ev_cpus->cpus);
if (map) if (map)
evsel->own_cpus = map; evsel->core.own_cpus = map;
else else
pr_err("failed to get event_update cpus\n"); pr_err("failed to get event_update cpus\n");
default: default:
......
...@@ -334,7 +334,7 @@ __add_event(struct list_head *list, int *idx, ...@@ -334,7 +334,7 @@ __add_event(struct list_head *list, int *idx,
(*idx)++; (*idx)++;
evsel->core.cpus = perf_cpu_map__get(cpus); evsel->core.cpus = perf_cpu_map__get(cpus);
evsel->own_cpus = perf_cpu_map__get(cpus); evsel->core.own_cpus = perf_cpu_map__get(cpus);
evsel->system_wide = pmu ? pmu->is_uncore : false; evsel->system_wide = pmu ? pmu->is_uncore : false;
evsel->auto_merge_stats = auto_merge_stats; evsel->auto_merge_stats = auto_merge_stats;
......
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