
Out of ad-hoc code and global arrays with hard coded sizes.
This is the first step on having a library that will be first
used on regression tests in the 'perf test' tool.
[acme@felicio linux]$ size /tmp/perf.before
text data bss dec hex filename
1273776
97384 5104416 6475576 62cf38 /tmp/perf.before
[acme@felicio linux]$ size /tmp/perf.new
text data bss dec hex filename
1275422 97416 1392416 2765254 2a31c6 /tmp/perf.new
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>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
36 lines
733 B
C
36 lines
733 B
C
#include "evsel.h"
|
|
#include "util.h"
|
|
|
|
struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx)
|
|
{
|
|
struct perf_evsel *evsel = zalloc(sizeof(*evsel));
|
|
|
|
if (evsel != NULL) {
|
|
evsel->idx = idx;
|
|
evsel->attr.type = type;
|
|
evsel->attr.config = config;
|
|
INIT_LIST_HEAD(&evsel->node);
|
|
}
|
|
|
|
return evsel;
|
|
}
|
|
|
|
int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
|
|
{
|
|
evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int));
|
|
return evsel->fd != NULL ? 0 : -ENOMEM;
|
|
}
|
|
|
|
void perf_evsel__free_fd(struct perf_evsel *evsel)
|
|
{
|
|
xyarray__delete(evsel->fd);
|
|
evsel->fd = NULL;
|
|
}
|
|
|
|
void perf_evsel__delete(struct perf_evsel *evsel)
|
|
{
|
|
assert(list_empty(&evsel->node));
|
|
xyarray__delete(evsel->fd);
|
|
free(evsel);
|
|
}
|