forked from Minki/linux
361c99a661
Killing two more perf wide global variables: nr_counters and evsel_list as a list_head. There are more operations that will need more fields in perf_evlist, like the pollfd for polling all the fds in a list of evsel instances. Use option->value to pass the evsel_list to parse_{events,filters}. LKML-Reference: <new-submission> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
54 lines
1.0 KiB
C
54 lines
1.0 KiB
C
#include "evlist.h"
|
|
#include "evsel.h"
|
|
#include "util.h"
|
|
|
|
struct perf_evlist *perf_evlist__new(void)
|
|
{
|
|
struct perf_evlist *evlist = zalloc(sizeof(*evlist));
|
|
|
|
if (evlist != NULL) {
|
|
INIT_LIST_HEAD(&evlist->entries);
|
|
}
|
|
|
|
return evlist;
|
|
}
|
|
|
|
static void perf_evlist__purge(struct perf_evlist *evlist)
|
|
{
|
|
struct perf_evsel *pos, *n;
|
|
|
|
list_for_each_entry_safe(pos, n, &evlist->entries, node) {
|
|
list_del_init(&pos->node);
|
|
perf_evsel__delete(pos);
|
|
}
|
|
|
|
evlist->nr_entries = 0;
|
|
}
|
|
|
|
void perf_evlist__delete(struct perf_evlist *evlist)
|
|
{
|
|
perf_evlist__purge(evlist);
|
|
free(evlist);
|
|
}
|
|
|
|
void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
|
|
{
|
|
list_add_tail(&entry->node, &evlist->entries);
|
|
++evlist->nr_entries;
|
|
}
|
|
|
|
int perf_evlist__add_default(struct perf_evlist *evlist)
|
|
{
|
|
struct perf_event_attr attr = {
|
|
.type = PERF_TYPE_HARDWARE,
|
|
.config = PERF_COUNT_HW_CPU_CYCLES,
|
|
};
|
|
struct perf_evsel *evsel = perf_evsel__new(&attr, 0);
|
|
|
|
if (evsel == NULL)
|
|
return -ENOMEM;
|
|
|
|
perf_evlist__add(evlist, evsel);
|
|
return 0;
|
|
}
|