mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 00:34:10 +08:00
perf tools: Use perf_evsel__newtp in the event parser
Elliminating code duplication. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-9v4zl7ldlp8v6azrpsu5lupk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e48ffe2bd4
commit
82fe1c290c
@ -356,42 +356,28 @@ int parse_events_add_cache(struct list_head **list, int *idx,
|
|||||||
return add_event(list, idx, &attr, name);
|
return add_event(list, idx, &attr, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_tracepoint(struct list_head **list, int *idx,
|
static int add_tracepoint(struct list_head **listp, int *idx,
|
||||||
char *sys_name, char *evt_name)
|
char *sys_name, char *evt_name)
|
||||||
{
|
{
|
||||||
struct perf_event_attr attr;
|
struct perf_evsel *evsel;
|
||||||
char name[MAX_NAME_LEN];
|
struct list_head *list = *listp;
|
||||||
char evt_path[MAXPATHLEN];
|
|
||||||
char id_buf[4];
|
|
||||||
u64 id;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", tracing_events_path,
|
if (!list) {
|
||||||
sys_name, evt_name);
|
list = malloc(sizeof(*list));
|
||||||
|
if (!list)
|
||||||
fd = open(evt_path, O_RDONLY);
|
return -ENOMEM;
|
||||||
if (fd < 0)
|
INIT_LIST_HEAD(list);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (read(fd, id_buf, sizeof(id_buf)) < 0) {
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
evsel = perf_evsel__newtp(sys_name, evt_name, (*idx)++);
|
||||||
id = atoll(id_buf);
|
if (!evsel) {
|
||||||
|
free(list);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&attr, 0, sizeof(attr));
|
list_add_tail(&evsel->node, list);
|
||||||
attr.config = id;
|
*listp = list;
|
||||||
attr.type = PERF_TYPE_TRACEPOINT;
|
return 0;
|
||||||
attr.sample_type |= PERF_SAMPLE_RAW;
|
|
||||||
attr.sample_type |= PERF_SAMPLE_TIME;
|
|
||||||
attr.sample_type |= PERF_SAMPLE_CPU;
|
|
||||||
attr.sample_type |= PERF_SAMPLE_PERIOD;
|
|
||||||
attr.sample_period = 1;
|
|
||||||
|
|
||||||
snprintf(name, MAX_NAME_LEN, "%s:%s", sys_name, evt_name);
|
|
||||||
return add_event(list, idx, &attr, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_tracepoint_multi(struct list_head **list, int *idx,
|
static int add_tracepoint_multi(struct list_head **list, int *idx,
|
||||||
|
Loading…
Reference in New Issue
Block a user