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

libperf: Move fd array from perf's evsel to lobperf's perf_evsel class

Move the fd array from perf's evsel to libperf's perf_evsel class.
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-59-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4b247fa7
...@@ -14,6 +14,7 @@ struct perf_evsel { ...@@ -14,6 +14,7 @@ struct perf_evsel {
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
struct perf_cpu_map *own_cpus; struct perf_cpu_map *own_cpus;
struct perf_thread_map *threads; struct perf_thread_map *threads;
struct xyarray *fd;
}; };
#endif /* __LIBPERF_INTERNAL_EVSEL_H */ #endif /* __LIBPERF_INTERNAL_EVSEL_H */
...@@ -1403,7 +1403,7 @@ static int ...@@ -1403,7 +1403,7 @@ static int
apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, apply_config_evsel_for_key(const char *name, int map_fd, void *pkey,
struct evsel *evsel) struct evsel *evsel)
{ {
struct xyarray *xy = evsel->fd; struct xyarray *xy = evsel->core.fd;
struct perf_event_attr *attr; struct perf_event_attr *attr;
unsigned int key, events; unsigned int key, events;
bool check_pass = false; bool check_pass = false;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
int sigqueue(pid_t pid, int sig, const union sigval value); int sigqueue(pid_t pid, int sig, const union sigval value);
#endif #endif
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) #define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))
#define SID(e, x, y) xyarray__entry(e->sample_id, x, y) #define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
...@@ -321,7 +321,7 @@ void evlist__disable(struct evlist *evlist) ...@@ -321,7 +321,7 @@ void evlist__disable(struct evlist *evlist)
struct evsel *pos; struct evsel *pos;
evlist__for_each_entry(evlist, pos) { evlist__for_each_entry(evlist, pos) {
if (pos->disabled || !perf_evsel__is_group_leader(pos) || !pos->fd) if (pos->disabled || !perf_evsel__is_group_leader(pos) || !pos->core.fd)
continue; continue;
evsel__disable(pos); evsel__disable(pos);
} }
...@@ -334,7 +334,7 @@ void evlist__enable(struct evlist *evlist) ...@@ -334,7 +334,7 @@ void evlist__enable(struct evlist *evlist)
struct evsel *pos; struct evsel *pos;
evlist__for_each_entry(evlist, pos) { evlist__for_each_entry(evlist, pos) {
if (!perf_evsel__is_group_leader(pos) || !pos->fd) if (!perf_evsel__is_group_leader(pos) || !pos->core.fd)
continue; continue;
evsel__enable(pos); evsel__enable(pos);
} }
...@@ -353,7 +353,7 @@ static int perf_evlist__enable_event_cpu(struct evlist *evlist, ...@@ -353,7 +353,7 @@ static int perf_evlist__enable_event_cpu(struct evlist *evlist,
int thread; int thread;
int nr_threads = perf_evlist__nr_threads(evlist, evsel); int nr_threads = perf_evlist__nr_threads(evlist, evsel);
if (!evsel->fd) if (!evsel->core.fd)
return -EINVAL; return -EINVAL;
for (thread = 0; thread < nr_threads; thread++) { for (thread = 0; thread < nr_threads; thread++) {
...@@ -371,7 +371,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, ...@@ -371,7 +371,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
int cpu; int cpu;
int nr_cpus = cpu_map__nr(evlist->core.cpus); int nr_cpus = cpu_map__nr(evlist->core.cpus);
if (!evsel->fd) if (!evsel->core.fd)
return -EINVAL; return -EINVAL;
for (cpu = 0; cpu < nr_cpus; cpu++) { for (cpu = 0; cpu < nr_cpus; cpu++) {
......
...@@ -90,7 +90,7 @@ int perf_evsel__object_config(size_t object_size, ...@@ -90,7 +90,7 @@ int perf_evsel__object_config(size_t object_size,
return 0; return 0;
} }
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) #define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))
int __perf_evsel__sample_size(u64 sample_type) int __perf_evsel__sample_size(u64 sample_type)
{ {
...@@ -1155,9 +1155,9 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, ...@@ -1155,9 +1155,9 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads)
{ {
evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int)); evsel->core.fd = xyarray__new(ncpus, nthreads, sizeof(int));
if (evsel->fd) { if (evsel->core.fd) {
int cpu, thread; int cpu, thread;
for (cpu = 0; cpu < ncpus; cpu++) { for (cpu = 0; cpu < ncpus; cpu++) {
for (thread = 0; thread < nthreads; thread++) { for (thread = 0; thread < nthreads; thread++) {
...@@ -1166,7 +1166,7 @@ static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) ...@@ -1166,7 +1166,7 @@ static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads)
} }
} }
return evsel->fd != NULL ? 0 : -ENOMEM; return evsel->core.fd != NULL ? 0 : -ENOMEM;
} }
static int perf_evsel__run_ioctl(struct evsel *evsel, static int perf_evsel__run_ioctl(struct evsel *evsel,
...@@ -1174,8 +1174,8 @@ static int perf_evsel__run_ioctl(struct evsel *evsel, ...@@ -1174,8 +1174,8 @@ static int perf_evsel__run_ioctl(struct evsel *evsel,
{ {
int cpu, thread; int cpu, thread;
for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) {
for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { for (thread = 0; thread < xyarray__max_y(evsel->core.fd); thread++) {
int fd = FD(evsel, cpu, thread), int fd = FD(evsel, cpu, thread),
err = ioctl(fd, ioc, arg); err = ioctl(fd, ioc, arg);
...@@ -1283,8 +1283,8 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads) ...@@ -1283,8 +1283,8 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads)
static void perf_evsel__free_fd(struct evsel *evsel) static void perf_evsel__free_fd(struct evsel *evsel)
{ {
xyarray__delete(evsel->fd); xyarray__delete(evsel->core.fd);
evsel->fd = NULL; evsel->core.fd = NULL;
} }
static void perf_evsel__free_id(struct evsel *evsel) static void perf_evsel__free_id(struct evsel *evsel)
...@@ -1309,8 +1309,8 @@ void perf_evsel__close_fd(struct evsel *evsel) ...@@ -1309,8 +1309,8 @@ void perf_evsel__close_fd(struct evsel *evsel)
{ {
int cpu, thread; int cpu, thread;
for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++)
for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) { for (thread = 0; thread < xyarray__max_y(evsel->core.fd); ++thread) {
close(FD(evsel, cpu, thread)); close(FD(evsel, cpu, thread));
FD(evsel, cpu, thread) = -1; FD(evsel, cpu, thread) = -1;
} }
...@@ -1555,7 +1555,7 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread) ...@@ -1555,7 +1555,7 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread)
* Leader must be already processed/open, * Leader must be already processed/open,
* if not it's a bug. * if not it's a bug.
*/ */
BUG_ON(!leader->fd); BUG_ON(!leader->core.fd);
fd = FD(leader, cpu, thread); fd = FD(leader, cpu, thread);
BUG_ON(fd == -1); BUG_ON(fd == -1);
...@@ -1865,7 +1865,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, ...@@ -1865,7 +1865,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
else else
nthreads = threads->nr; nthreads = threads->nr;
if (evsel->fd == NULL && if (evsel->core.fd == NULL &&
perf_evsel__alloc_fd(evsel, cpus->nr, nthreads) < 0) perf_evsel__alloc_fd(evsel, cpus->nr, nthreads) < 0)
return -ENOMEM; return -ENOMEM;
...@@ -2075,7 +2075,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, ...@@ -2075,7 +2075,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
void perf_evsel__close(struct evsel *evsel) void perf_evsel__close(struct evsel *evsel)
{ {
if (evsel->fd == NULL) if (evsel->core.fd == NULL)
return; return;
perf_evsel__close_fd(evsel); perf_evsel__close_fd(evsel);
...@@ -3048,8 +3048,8 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist) ...@@ -3048,8 +3048,8 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)
{ {
int cpu, thread; int cpu, thread;
for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) {
for (thread = 0; thread < xyarray__max_y(evsel->fd); for (thread = 0; thread < xyarray__max_y(evsel->core.fd);
thread++) { thread++) {
int fd = FD(evsel, cpu, thread); int fd = FD(evsel, cpu, thread);
......
...@@ -104,7 +104,6 @@ struct evsel { ...@@ -104,7 +104,6 @@ struct evsel {
struct perf_evsel core; struct perf_evsel core;
struct evlist *evlist; struct evlist *evlist;
char *filter; char *filter;
struct xyarray *fd;
struct xyarray *sample_id; struct xyarray *sample_id;
u64 *id; u64 *id;
struct perf_counts *counts; struct perf_counts *counts;
......
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