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

libperf: Include perf_evlist in evlist object

Include perf_evlist in the evlist object, will continue to move other
generic things into libperf's perf_evlist.
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-37-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b27c4ece
...@@ -1002,7 +1002,7 @@ static void record__init_features(struct record *rec) ...@@ -1002,7 +1002,7 @@ static void record__init_features(struct record *rec)
if (rec->no_buildid) if (rec->no_buildid)
perf_header__clear_feat(&session->header, HEADER_BUILD_ID); perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
if (!have_tracepoints(&rec->evlist->entries)) if (!have_tracepoints(&rec->evlist->core.entries))
perf_header__clear_feat(&session->header, HEADER_TRACING_DATA); perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
if (!rec->opts.branch_stack) if (!rec->opts.branch_stack)
...@@ -1218,7 +1218,7 @@ static int record__synthesize(struct record *rec, bool tail) ...@@ -1218,7 +1218,7 @@ static int record__synthesize(struct record *rec, bool tail)
return err; return err;
} }
if (have_tracepoints(&rec->evlist->entries)) { if (have_tracepoints(&rec->evlist->core.entries)) {
/* /*
* FIXME err <= 0 here actually means that * FIXME err <= 0 here actually means that
* there were no tracepoints so its not really * there were no tracepoints so its not really
......
...@@ -2929,7 +2929,7 @@ static int timehist_check_attr(struct perf_sched *sched, ...@@ -2929,7 +2929,7 @@ static int timehist_check_attr(struct perf_sched *sched,
struct evsel *evsel; struct evsel *evsel;
struct evsel_runtime *er; struct evsel_runtime *er;
list_for_each_entry(evsel, &evlist->entries, core.node) { list_for_each_entry(evsel, &evlist->core.entries, core.node) {
er = perf_evsel__get_runtime(evsel); er = perf_evsel__get_runtime(evsel);
if (er == NULL) { if (er == NULL) {
pr_err("Failed to allocate memory for evsel runtime data\n"); pr_err("Failed to allocate memory for evsel runtime data\n");
......
...@@ -3980,7 +3980,7 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u ...@@ -3980,7 +3980,7 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u
{ {
struct trace *trace = opt->value; struct trace *trace = opt->value;
if (!list_empty(&trace->evlist->entries)) if (!list_empty(&trace->evlist->core.entries))
return parse_cgroups(opt, str, unset); return parse_cgroups(opt, str, unset);
trace->cgroup = evlist__findnew_cgroup(trace->evlist, str); trace->cgroup = evlist__findnew_cgroup(trace->evlist, str);
......
...@@ -3309,13 +3309,13 @@ static int perf_evsel_menu__run(struct evsel_menu *menu, ...@@ -3309,13 +3309,13 @@ static int perf_evsel_menu__run(struct evsel_menu *menu,
ui_browser__show_title(&menu->b, title); ui_browser__show_title(&menu->b, title);
switch (key) { switch (key) {
case K_TAB: case K_TAB:
if (pos->core.node.next == &evlist->entries) if (pos->core.node.next == &evlist->core.entries)
pos = perf_evlist__first(evlist); pos = perf_evlist__first(evlist);
else else
pos = perf_evsel__next(pos); pos = perf_evsel__next(pos);
goto browse_hists; goto browse_hists;
case K_UNTAB: case K_UNTAB:
if (pos->core.node.prev == &evlist->entries) if (pos->core.node.prev == &evlist->core.entries)
pos = perf_evlist__last(evlist); pos = perf_evlist__last(evlist);
else else
pos = perf_evsel__prev(pos); pos = perf_evsel__prev(pos);
...@@ -3370,7 +3370,7 @@ static int __perf_evlist__tui_browse_hists(struct evlist *evlist, ...@@ -3370,7 +3370,7 @@ static int __perf_evlist__tui_browse_hists(struct evlist *evlist,
struct evsel *pos; struct evsel *pos;
struct evsel_menu menu = { struct evsel_menu menu = {
.b = { .b = {
.entries = &evlist->entries, .entries = &evlist->core.entries,
.refresh = ui_browser__list_head_refresh, .refresh = ui_browser__list_head_refresh,
.seek = ui_browser__list_head_seek, .seek = ui_browser__list_head_seek,
.write = perf_evsel_menu__write, .write = perf_evsel_menu__write,
......
...@@ -208,7 +208,7 @@ int parse_cgroups(const struct option *opt, const char *str, ...@@ -208,7 +208,7 @@ int parse_cgroups(const struct option *opt, const char *str,
char *s; char *s;
int ret, i; int ret, i;
if (list_empty(&evlist->entries)) { if (list_empty(&evlist->core.entries)) {
fprintf(stderr, "must define events before cgroups\n"); fprintf(stderr, "must define events before cgroups\n");
return -1; return -1;
} }
......
...@@ -48,7 +48,7 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, ...@@ -48,7 +48,7 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i) for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i)
INIT_HLIST_HEAD(&evlist->heads[i]); INIT_HLIST_HEAD(&evlist->heads[i]);
INIT_LIST_HEAD(&evlist->entries); INIT_LIST_HEAD(&evlist->core.entries);
perf_evlist__set_maps(evlist, cpus, threads); perf_evlist__set_maps(evlist, cpus, threads);
fdarray__init(&evlist->pollfd, 64); fdarray__init(&evlist->pollfd, 64);
evlist->workload.pid = -1; evlist->workload.pid = -1;
...@@ -180,7 +180,7 @@ static void perf_evlist__propagate_maps(struct evlist *evlist) ...@@ -180,7 +180,7 @@ static void perf_evlist__propagate_maps(struct evlist *evlist)
void evlist__add(struct evlist *evlist, struct evsel *entry) void evlist__add(struct evlist *evlist, struct evsel *entry)
{ {
entry->evlist = evlist; entry->evlist = evlist;
list_add_tail(&entry->core.node, &evlist->entries); list_add_tail(&entry->core.node, &evlist->core.entries);
entry->idx = evlist->nr_entries; entry->idx = evlist->nr_entries;
entry->tracking = !entry->idx; entry->tracking = !entry->idx;
...@@ -226,7 +226,7 @@ void perf_evlist__set_leader(struct evlist *evlist) ...@@ -226,7 +226,7 @@ void perf_evlist__set_leader(struct evlist *evlist)
{ {
if (evlist->nr_entries) { if (evlist->nr_entries) {
evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0; evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0;
__perf_evlist__set_leader(&evlist->entries); __perf_evlist__set_leader(&evlist->core.entries);
} }
} }
...@@ -1683,7 +1683,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -1683,7 +1683,7 @@ void perf_evlist__to_front(struct evlist *evlist,
list_move_tail(&evsel->core.node, &move); list_move_tail(&evsel->core.node, &move);
} }
list_splice(&move, &evlist->entries); list_splice(&move, &evlist->core.entries);
} }
void perf_evlist__set_tracking_event(struct evlist *evlist, void perf_evlist__set_tracking_event(struct evlist *evlist,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <api/fd/array.h> #include <api/fd/array.h>
#include <stdio.h> #include <stdio.h>
#include <internal/evlist.h>
#include "../perf.h" #include "../perf.h"
#include "event.h" #include "event.h"
#include "evsel.h" #include "evsel.h"
...@@ -25,7 +26,7 @@ struct record_opts; ...@@ -25,7 +26,7 @@ struct record_opts;
#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS) #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
struct evlist { struct evlist {
struct list_head entries; struct perf_evlist core;
struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
int nr_entries; int nr_entries;
int nr_groups; int nr_groups;
...@@ -225,17 +226,17 @@ void perf_evlist__splice_list_tail(struct evlist *evlist, ...@@ -225,17 +226,17 @@ void perf_evlist__splice_list_tail(struct evlist *evlist,
static inline bool perf_evlist__empty(struct evlist *evlist) static inline bool perf_evlist__empty(struct evlist *evlist)
{ {
return list_empty(&evlist->entries); return list_empty(&evlist->core.entries);
} }
static inline struct evsel *perf_evlist__first(struct evlist *evlist) static inline struct evsel *perf_evlist__first(struct evlist *evlist)
{ {
return list_entry(evlist->entries.next, struct evsel, core.node); return list_entry(evlist->core.entries.next, struct evsel, core.node);
} }
static inline struct evsel *perf_evlist__last(struct evlist *evlist) static inline struct evsel *perf_evlist__last(struct evlist *evlist)
{ {
return list_entry(evlist->entries.prev, struct evsel, core.node); return list_entry(evlist->core.entries.prev, struct evsel, core.node);
} }
size_t perf_evlist__fprintf(struct evlist *evlist, FILE *fp); size_t perf_evlist__fprintf(struct evlist *evlist, FILE *fp);
...@@ -261,7 +262,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -261,7 +262,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define evlist__for_each_entry(evlist, evsel) \ #define evlist__for_each_entry(evlist, evsel) \
__evlist__for_each_entry(&(evlist)->entries, evsel) __evlist__for_each_entry(&(evlist)->core.entries, evsel)
/** /**
* __evlist__for_each_entry_continue - continue iteration thru all the evsels * __evlist__for_each_entry_continue - continue iteration thru all the evsels
...@@ -277,7 +278,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -277,7 +278,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define evlist__for_each_entry_continue(evlist, evsel) \ #define evlist__for_each_entry_continue(evlist, evsel) \
__evlist__for_each_entry_continue(&(evlist)->entries, evsel) __evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
/** /**
* __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
...@@ -293,7 +294,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -293,7 +294,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define evlist__for_each_entry_reverse(evlist, evsel) \ #define evlist__for_each_entry_reverse(evlist, evsel) \
__evlist__for_each_entry_reverse(&(evlist)->entries, evsel) __evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
/** /**
* __evlist__for_each_entry_safe - safely iterate thru all the evsels * __evlist__for_each_entry_safe - safely iterate thru all the evsels
...@@ -311,7 +312,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -311,7 +312,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @tmp: struct evsel temp iterator * @tmp: struct evsel temp iterator
*/ */
#define evlist__for_each_entry_safe(evlist, tmp, evsel) \ #define evlist__for_each_entry_safe(evlist, tmp, evsel) \
__evlist__for_each_entry_safe(&(evlist)->entries, tmp, evsel) __evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
void perf_evlist__set_tracking_event(struct evlist *evlist, void perf_evlist__set_tracking_event(struct evlist *evlist,
struct evsel *tracking_evsel); struct evsel *tracking_evsel);
......
...@@ -304,7 +304,7 @@ static int write_tracing_data(struct feat_fd *ff, ...@@ -304,7 +304,7 @@ static int write_tracing_data(struct feat_fd *ff,
if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
return -1; return -1;
return read_tracing_data(ff->fd, &evlist->entries); return read_tracing_data(ff->fd, &evlist->core.entries);
} }
static int write_build_id(struct feat_fd *ff, static int write_build_id(struct feat_fd *ff,
...@@ -4112,7 +4112,7 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, ...@@ -4112,7 +4112,7 @@ int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
* - write the tracing data from the temp file * - write the tracing data from the temp file
* to the pipe * to the pipe
*/ */
tdata = tracing_data_get(&evlist->entries, fd, true); tdata = tracing_data_get(&evlist->core.entries, fd, true);
if (!tdata) if (!tdata)
return -1; return -1;
......
...@@ -2050,7 +2050,7 @@ foreach_evsel_in_last_glob(struct evlist *evlist, ...@@ -2050,7 +2050,7 @@ foreach_evsel_in_last_glob(struct evlist *evlist,
if (!last) if (!last)
return 0; return 0;
if (last->core.node.prev == &evlist->entries) if (last->core.node.prev == &evlist->core.entries)
return 0; return 0;
last = list_entry(last->core.node.prev, struct evsel, core.node); last = list_entry(last->core.node.prev, struct evsel, core.node);
} while (!last->cmdline_group_boundary); } while (!last->cmdline_group_boundary);
......
...@@ -548,8 +548,8 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c ...@@ -548,8 +548,8 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c
struct evlist *evlist = counter->evlist; struct evlist *evlist = counter->evlist;
struct evsel *alias; struct evsel *alias;
alias = list_prepare_entry(counter, &(evlist->entries), core.node); alias = list_prepare_entry(counter, &(evlist->core.entries), core.node);
list_for_each_entry_continue (alias, &evlist->entries, core.node) { list_for_each_entry_continue (alias, &evlist->core.entries, core.node) {
if (strcmp(perf_evsel__name(alias), perf_evsel__name(counter)) || if (strcmp(perf_evsel__name(alias), perf_evsel__name(counter)) ||
alias->scale != counter->scale || alias->scale != counter->scale ||
alias->cgrp != counter->cgrp || alias->cgrp != counter->cgrp ||
......
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