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

libperf: Include perf_evsel in evsel object

Including perf_evsel in evsel object, will continue to move other
generic things into libperf's perf_evsel struct.
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-36-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 285a30c3
...@@ -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, node) { list_for_each_entry(evsel, &evlist->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");
......
...@@ -2636,7 +2636,7 @@ static bool evlist__add_vfs_getname(struct evlist *evlist) ...@@ -2636,7 +2636,7 @@ static bool evlist__add_vfs_getname(struct evlist *evlist)
continue; continue;
} }
list_del_init(&evsel->node); list_del_init(&evsel->core.node);
evsel->evlist = NULL; evsel->evlist = NULL;
evsel__delete(evsel); evsel__delete(evsel);
} }
......
...@@ -3212,7 +3212,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser, ...@@ -3212,7 +3212,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
{ {
struct evsel_menu *menu = container_of(browser, struct evsel_menu *menu = container_of(browser,
struct evsel_menu, b); struct evsel_menu, b);
struct evsel *evsel = list_entry(entry, struct evsel, node); struct evsel *evsel = list_entry(entry, struct evsel, core.node);
struct hists *hists = evsel__hists(evsel); struct hists *hists = evsel__hists(evsel);
bool current_entry = ui_browser__is_current_entry(browser, row); bool current_entry = ui_browser__is_current_entry(browser, row);
unsigned long nr_events = hists->stats.nr_events[PERF_RECORD_SAMPLE]; unsigned long nr_events = hists->stats.nr_events[PERF_RECORD_SAMPLE];
...@@ -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->node.next == &evlist->entries) if (pos->core.node.next == &evlist->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->node.prev == &evlist->entries) if (pos->core.node.prev == &evlist->entries)
pos = perf_evlist__last(evlist); pos = perf_evlist__last(evlist);
else else
pos = perf_evsel__prev(pos); pos = perf_evsel__prev(pos);
...@@ -3351,7 +3351,7 @@ static int perf_evsel_menu__run(struct evsel_menu *menu, ...@@ -3351,7 +3351,7 @@ static int perf_evsel_menu__run(struct evsel_menu *menu,
static bool filter_group_entries(struct ui_browser *browser __maybe_unused, static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
void *entry) void *entry)
{ {
struct evsel *evsel = list_entry(entry, struct evsel, node); struct evsel *evsel = list_entry(entry, struct evsel, core.node);
if (symbol_conf.event_group && !perf_evsel__is_group_leader(evsel)) if (symbol_conf.event_group && !perf_evsel__is_group_leader(evsel))
return true; return true;
......
...@@ -119,7 +119,7 @@ static void perf_evlist__purge(struct evlist *evlist) ...@@ -119,7 +119,7 @@ static void perf_evlist__purge(struct evlist *evlist)
struct evsel *pos, *n; struct evsel *pos, *n;
evlist__for_each_entry_safe(evlist, n, pos) { evlist__for_each_entry_safe(evlist, n, pos) {
list_del_init(&pos->node); list_del_init(&pos->core.node);
pos->evlist = NULL; pos->evlist = NULL;
evsel__delete(pos); evsel__delete(pos);
} }
...@@ -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->node, &evlist->entries); list_add_tail(&entry->core.node, &evlist->entries);
entry->idx = evlist->nr_entries; entry->idx = evlist->nr_entries;
entry->tracking = !entry->idx; entry->tracking = !entry->idx;
...@@ -193,7 +193,7 @@ void evlist__add(struct evlist *evlist, struct evsel *entry) ...@@ -193,7 +193,7 @@ void evlist__add(struct evlist *evlist, struct evsel *entry)
void evlist__remove(struct evlist *evlist, struct evsel *evsel) void evlist__remove(struct evlist *evlist, struct evsel *evsel)
{ {
evsel->evlist = NULL; evsel->evlist = NULL;
list_del_init(&evsel->node); list_del_init(&evsel->core.node);
evlist->nr_entries -= 1; evlist->nr_entries -= 1;
} }
...@@ -203,7 +203,7 @@ void perf_evlist__splice_list_tail(struct evlist *evlist, ...@@ -203,7 +203,7 @@ void perf_evlist__splice_list_tail(struct evlist *evlist,
struct evsel *evsel, *temp; struct evsel *evsel, *temp;
__evlist__for_each_entry_safe(list, temp, evsel) { __evlist__for_each_entry_safe(list, temp, evsel) {
list_del_init(&evsel->node); list_del_init(&evsel->core.node);
evlist__add(evlist, evsel); evlist__add(evlist, evsel);
} }
} }
...@@ -212,8 +212,8 @@ void __perf_evlist__set_leader(struct list_head *list) ...@@ -212,8 +212,8 @@ void __perf_evlist__set_leader(struct list_head *list)
{ {
struct evsel *evsel, *leader; struct evsel *evsel, *leader;
leader = list_entry(list->next, struct evsel, node); leader = list_entry(list->next, struct evsel, core.node);
evsel = list_entry(list->prev, struct evsel, node); evsel = list_entry(list->prev, struct evsel, core.node);
leader->nr_members = evsel->idx - leader->idx + 1; leader->nr_members = evsel->idx - leader->idx + 1;
...@@ -268,7 +268,7 @@ static int evlist__add_attrs(struct evlist *evlist, ...@@ -268,7 +268,7 @@ static int evlist__add_attrs(struct evlist *evlist,
evsel = perf_evsel__new_idx(attrs + i, evlist->nr_entries + i); evsel = perf_evsel__new_idx(attrs + i, evlist->nr_entries + i);
if (evsel == NULL) if (evsel == NULL)
goto out_delete_partial_list; goto out_delete_partial_list;
list_add_tail(&evsel->node, &head); list_add_tail(&evsel->core.node, &head);
} }
perf_evlist__splice_list_tail(evlist, &head); perf_evlist__splice_list_tail(evlist, &head);
...@@ -1680,7 +1680,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -1680,7 +1680,7 @@ void perf_evlist__to_front(struct evlist *evlist,
evlist__for_each_entry_safe(evlist, n, evsel) { evlist__for_each_entry_safe(evlist, n, evsel) {
if (evsel->leader == move_evsel->leader) if (evsel->leader == move_evsel->leader)
list_move_tail(&evsel->node, &move); list_move_tail(&evsel->core.node, &move);
} }
list_splice(&move, &evlist->entries); list_splice(&move, &evlist->entries);
......
...@@ -230,12 +230,12 @@ static inline bool perf_evlist__empty(struct evlist *evlist) ...@@ -230,12 +230,12 @@ static inline bool perf_evlist__empty(struct evlist *evlist)
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, node); return list_entry(evlist->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, node); return list_entry(evlist->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);
...@@ -253,7 +253,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -253,7 +253,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define __evlist__for_each_entry(list, evsel) \ #define __evlist__for_each_entry(list, evsel) \
list_for_each_entry(evsel, list, node) list_for_each_entry(evsel, list, core.node)
/** /**
* evlist__for_each_entry - iterate thru all the evsels * evlist__for_each_entry - iterate thru all the evsels
...@@ -269,7 +269,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -269,7 +269,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define __evlist__for_each_entry_continue(list, evsel) \ #define __evlist__for_each_entry_continue(list, evsel) \
list_for_each_entry_continue(evsel, list, node) list_for_each_entry_continue(evsel, list, core.node)
/** /**
* evlist__for_each_entry_continue - continue iteration thru all the evsels * evlist__for_each_entry_continue - continue iteration thru all the evsels
...@@ -285,7 +285,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -285,7 +285,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define __evlist__for_each_entry_reverse(list, evsel) \ #define __evlist__for_each_entry_reverse(list, evsel) \
list_for_each_entry_reverse(evsel, list, node) list_for_each_entry_reverse(evsel, list, core.node)
/** /**
* 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
...@@ -302,7 +302,7 @@ void perf_evlist__to_front(struct evlist *evlist, ...@@ -302,7 +302,7 @@ void perf_evlist__to_front(struct evlist *evlist,
* @evsel: struct evsel iterator * @evsel: struct evsel iterator
*/ */
#define __evlist__for_each_entry_safe(list, tmp, evsel) \ #define __evlist__for_each_entry_safe(list, tmp, evsel) \
list_for_each_entry_safe(evsel, tmp, list, node) list_for_each_entry_safe(evsel, tmp, list, core.node)
/** /**
* evlist__for_each_entry_safe - safely iterate thru all the evsels * evlist__for_each_entry_safe - safely iterate thru all the evsels
......
...@@ -236,7 +236,7 @@ void evsel__init(struct evsel *evsel, ...@@ -236,7 +236,7 @@ void evsel__init(struct evsel *evsel,
evsel->evlist = NULL; evsel->evlist = NULL;
evsel->bpf_obj = NULL; evsel->bpf_obj = NULL;
evsel->bpf_fd = -1; evsel->bpf_fd = -1;
INIT_LIST_HEAD(&evsel->node); INIT_LIST_HEAD(&evsel->core.node);
INIT_LIST_HEAD(&evsel->config_terms); INIT_LIST_HEAD(&evsel->config_terms);
perf_evsel__object.init(evsel); perf_evsel__object.init(evsel);
evsel->sample_size = __perf_evsel__sample_size(attr->sample_type); evsel->sample_size = __perf_evsel__sample_size(attr->sample_type);
...@@ -1318,7 +1318,7 @@ void perf_evsel__close_fd(struct evsel *evsel) ...@@ -1318,7 +1318,7 @@ void perf_evsel__close_fd(struct evsel *evsel)
void perf_evsel__exit(struct evsel *evsel) void perf_evsel__exit(struct evsel *evsel)
{ {
assert(list_empty(&evsel->node)); assert(list_empty(&evsel->core.node));
assert(evsel->evlist == NULL); assert(evsel->evlist == NULL);
perf_evsel__free_counts(evsel); perf_evsel__free_counts(evsel);
perf_evsel__free_fd(evsel); perf_evsel__free_fd(evsel);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stddef.h> #include <stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/types.h> #include <linux/types.h>
#include <internal/evsel.h>
#include "xyarray.h" #include "xyarray.h"
#include "symbol_conf.h" #include "symbol_conf.h"
#include "cpumap.h" #include "cpumap.h"
...@@ -87,8 +88,7 @@ struct bpf_object; ...@@ -87,8 +88,7 @@ struct bpf_object;
/** struct evsel - event selector /** struct evsel - event selector
* *
* @evlist - evlist this evsel is in, if it is in one. * @evlist - evlist this evsel is in, if it is in one.
* @node - To insert it into evlist->entries or in other list_heads, say in * @core - libperf evsel object
* the event parsing routines.
* @name - Can be set to retain the original event name passed by the user, * @name - Can be set to retain the original event name passed by the user,
* so that when showing results in tools such as 'perf stat', we * so that when showing results in tools such as 'perf stat', we
* show the name used, not some alias. * show the name used, not some alias.
...@@ -101,7 +101,7 @@ struct bpf_object; ...@@ -101,7 +101,7 @@ struct bpf_object;
* @priv: And what is in its containing unnamed union are tool specific * @priv: And what is in its containing unnamed union are tool specific
*/ */
struct evsel { struct evsel {
struct list_head node; struct perf_evsel core;
struct evlist *evlist; struct evlist *evlist;
struct perf_event_attr attr; struct perf_event_attr attr;
char *filter; char *filter;
...@@ -386,12 +386,12 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel, ...@@ -386,12 +386,12 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel,
static inline struct evsel *perf_evsel__next(struct evsel *evsel) static inline struct evsel *perf_evsel__next(struct evsel *evsel)
{ {
return list_entry(evsel->node.next, struct evsel, node); return list_entry(evsel->core.node.next, struct evsel, core.node);
} }
static inline struct evsel *perf_evsel__prev(struct evsel *evsel) static inline struct evsel *perf_evsel__prev(struct evsel *evsel)
{ {
return list_entry(evsel->node.prev, struct evsel, node); return list_entry(evsel->core.node.prev, struct evsel, core.node);
} }
/** /**
...@@ -478,15 +478,15 @@ static inline int perf_evsel__group_idx(struct evsel *evsel) ...@@ -478,15 +478,15 @@ static inline int perf_evsel__group_idx(struct evsel *evsel)
/* Iterates group WITHOUT the leader. */ /* Iterates group WITHOUT the leader. */
#define for_each_group_member(_evsel, _leader) \ #define for_each_group_member(_evsel, _leader) \
for ((_evsel) = list_entry((_leader)->node.next, struct evsel, node); \ for ((_evsel) = list_entry((_leader)->core.node.next, struct evsel, core.node); \
(_evsel) && (_evsel)->leader == (_leader); \ (_evsel) && (_evsel)->leader == (_leader); \
(_evsel) = list_entry((_evsel)->node.next, struct evsel, node)) (_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node))
/* Iterates group WITH the leader. */ /* Iterates group WITH the leader. */
#define for_each_group_evsel(_evsel, _leader) \ #define for_each_group_evsel(_evsel, _leader) \
for ((_evsel) = _leader; \ for ((_evsel) = _leader; \
(_evsel) && (_evsel)->leader == (_leader); \ (_evsel) && (_evsel)->leader == (_leader); \
(_evsel) = list_entry((_evsel)->node.next, struct evsel, node)) (_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node))
static inline bool perf_evsel__has_branch_callstack(const struct evsel *evsel) static inline bool perf_evsel__has_branch_callstack(const struct evsel *evsel)
{ {
......
...@@ -343,7 +343,7 @@ __add_event(struct list_head *list, int *idx, ...@@ -343,7 +343,7 @@ __add_event(struct list_head *list, int *idx,
if (config_terms) if (config_terms)
list_splice(config_terms, &evsel->config_terms); list_splice(config_terms, &evsel->config_terms);
list_add_tail(&evsel->node, list); list_add_tail(&evsel->core.node, list);
return evsel; return evsel;
} }
...@@ -526,7 +526,7 @@ static int add_tracepoint(struct list_head *list, int *idx, ...@@ -526,7 +526,7 @@ static int add_tracepoint(struct list_head *list, int *idx,
list_splice(&config_terms, &evsel->config_terms); list_splice(&config_terms, &evsel->config_terms);
} }
list_add_tail(&evsel->node, list); list_add_tail(&evsel->core.node, list);
return 0; return 0;
} }
...@@ -660,15 +660,15 @@ static int add_bpf_event(const char *group, const char *event, int fd, struct bp ...@@ -660,15 +660,15 @@ static int add_bpf_event(const char *group, const char *event, int fd, struct bp
pr_debug("Failed to add BPF event %s:%s\n", pr_debug("Failed to add BPF event %s:%s\n",
group, event); group, event);
list_for_each_entry_safe(evsel, tmp, &new_evsels, node) { list_for_each_entry_safe(evsel, tmp, &new_evsels, core.node) {
list_del_init(&evsel->node); list_del_init(&evsel->core.node);
evsel__delete(evsel); evsel__delete(evsel);
} }
return err; return err;
} }
pr_debug("adding %s:%s\n", group, event); pr_debug("adding %s:%s\n", group, event);
list_for_each_entry(pos, &new_evsels, node) { list_for_each_entry(pos, &new_evsels, core.node) {
pr_debug("adding %s:%s to %p\n", pr_debug("adding %s:%s to %p\n",
group, event, pos); group, event, pos);
pos->bpf_fd = fd; pos->bpf_fd = fd;
...@@ -1458,8 +1458,8 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, ...@@ -1458,8 +1458,8 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
bool is_leader = true; bool is_leader = true;
int i, nr_pmu = 0, total_members, ret = 0; int i, nr_pmu = 0, total_members, ret = 0;
leader = list_first_entry(list, struct evsel, node); leader = list_first_entry(list, struct evsel, core.node);
evsel = list_last_entry(list, struct evsel, node); evsel = list_last_entry(list, struct evsel, core.node);
total_members = evsel->idx - leader->idx + 1; total_members = evsel->idx - leader->idx + 1;
leaders = calloc(total_members, sizeof(uintptr_t)); leaders = calloc(total_members, sizeof(uintptr_t));
...@@ -1555,7 +1555,7 @@ void parse_events__set_leader(char *name, struct list_head *list, ...@@ -1555,7 +1555,7 @@ void parse_events__set_leader(char *name, struct list_head *list,
return; return;
__perf_evlist__set_leader(list); __perf_evlist__set_leader(list);
leader = list_entry(list->next, struct evsel, node); leader = list_entry(list->next, struct evsel, core.node);
leader->group_name = name ? strdup(name) : NULL; leader->group_name = name ? strdup(name) : NULL;
} }
...@@ -2050,9 +2050,9 @@ foreach_evsel_in_last_glob(struct evlist *evlist, ...@@ -2050,9 +2050,9 @@ foreach_evsel_in_last_glob(struct evlist *evlist,
if (!last) if (!last)
return 0; return 0;
if (last->node.prev == &evlist->entries) if (last->core.node.prev == &evlist->entries)
return 0; return 0;
last = list_entry(last->node.prev, struct evsel, node); last = list_entry(last->core.node.prev, struct evsel, core.node);
} while (!last->cmdline_group_boundary); } while (!last->cmdline_group_boundary);
return 0; return 0;
......
...@@ -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), node); alias = list_prepare_entry(counter, &(evlist->entries), core.node);
list_for_each_entry_continue (alias, &evlist->entries, node) { list_for_each_entry_continue (alias, &evlist->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 ||
......
...@@ -408,7 +408,7 @@ get_tracepoints_path(struct list_head *pattrs) ...@@ -408,7 +408,7 @@ get_tracepoints_path(struct list_head *pattrs)
struct evsel *pos; struct evsel *pos;
int nr_tracepoints = 0; int nr_tracepoints = 0;
list_for_each_entry(pos, pattrs, node) { list_for_each_entry(pos, pattrs, core.node) {
if (pos->attr.type != PERF_TYPE_TRACEPOINT) if (pos->attr.type != PERF_TYPE_TRACEPOINT)
continue; continue;
++nr_tracepoints; ++nr_tracepoints;
...@@ -443,7 +443,7 @@ bool have_tracepoints(struct list_head *pattrs) ...@@ -443,7 +443,7 @@ bool have_tracepoints(struct list_head *pattrs)
{ {
struct evsel *pos; struct evsel *pos;
list_for_each_entry(pos, pattrs, node) list_for_each_entry(pos, pattrs, core.node)
if (pos->attr.type == PERF_TYPE_TRACEPOINT) if (pos->attr.type == PERF_TYPE_TRACEPOINT)
return true; return true;
......
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