perf event: perf_event_ops->attr() manipulates only an evlist

Removing another case where a perf_session is required when processing
events.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
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-ug1wtjbnva4bxwknflkkrlrh@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 81e36bff
...@@ -36,6 +36,12 @@ static int perf_event__repipe_synth(union perf_event *event, ...@@ -36,6 +36,12 @@ static int perf_event__repipe_synth(union perf_event *event,
return 0; return 0;
} }
static int perf_event__repipe_attr(union perf_event *event,
struct perf_evlist **pevlist __used)
{
return perf_event__repipe_synth(event, NULL);
}
static int perf_event__repipe(union perf_event *event, static int perf_event__repipe(union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session) struct perf_session *session)
...@@ -182,7 +188,7 @@ struct perf_event_ops inject_ops = { ...@@ -182,7 +188,7 @@ struct perf_event_ops inject_ops = {
.read = perf_event__repipe, .read = perf_event__repipe,
.throttle = perf_event__repipe, .throttle = perf_event__repipe,
.unthrottle = perf_event__repipe, .unthrottle = perf_event__repipe,
.attr = perf_event__repipe_synth, .attr = perf_event__repipe_attr,
.event_type = perf_event__repipe_synth, .event_type = perf_event__repipe_synth,
.tracing_data = perf_event__repipe_synth, .tracing_data = perf_event__repipe_synth,
.build_id = perf_event__repipe_synth, .build_id = perf_event__repipe_synth,
......
...@@ -2120,23 +2120,23 @@ int perf_session__synthesize_attrs(struct perf_session *session, ...@@ -2120,23 +2120,23 @@ int perf_session__synthesize_attrs(struct perf_session *session,
} }
int perf_event__process_attr(union perf_event *event, int perf_event__process_attr(union perf_event *event,
struct perf_session *session) struct perf_evlist **pevlist)
{ {
unsigned int i, ids, n_ids; unsigned int i, ids, n_ids;
struct perf_evsel *evsel; struct perf_evsel *evsel;
struct perf_evlist *evlist = *pevlist;
if (session->evlist == NULL) { if (evlist == NULL) {
session->evlist = perf_evlist__new(NULL, NULL); *pevlist = evlist = perf_evlist__new(NULL, NULL);
if (session->evlist == NULL) if (evlist == NULL)
return -ENOMEM; return -ENOMEM;
} }
evsel = perf_evsel__new(&event->attr.attr, evsel = perf_evsel__new(&event->attr.attr, evlist->nr_entries);
session->evlist->nr_entries);
if (evsel == NULL) if (evsel == NULL)
return -ENOMEM; return -ENOMEM;
perf_evlist__add(session->evlist, evsel); perf_evlist__add(evlist, evsel);
ids = event->header.size; ids = event->header.size;
ids -= (void *)&event->attr.id - (void *)event; ids -= (void *)&event->attr.id - (void *)event;
...@@ -2150,12 +2150,9 @@ int perf_event__process_attr(union perf_event *event, ...@@ -2150,12 +2150,9 @@ int perf_event__process_attr(union perf_event *event,
return -ENOMEM; return -ENOMEM;
for (i = 0; i < n_ids; i++) { for (i = 0; i < n_ids; i++) {
perf_evlist__id_add(session->evlist, evsel, 0, i, perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]);
event->attr.id[i]);
} }
perf_session__update_sample_type(session);
return 0; return 0;
} }
......
...@@ -101,7 +101,7 @@ int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, ...@@ -101,7 +101,7 @@ int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
struct perf_session *session); struct perf_session *session);
int perf_session__synthesize_attrs(struct perf_session *session, int perf_session__synthesize_attrs(struct perf_session *session,
perf_event__handler_t process); perf_event__handler_t process);
int perf_event__process_attr(union perf_event *event, struct perf_session *session); int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist);
int perf_event__synthesize_event_type(u64 event_id, char *name, int perf_event__synthesize_event_type(u64 event_id, char *name,
perf_event__handler_t process, perf_event__handler_t process,
......
...@@ -277,6 +277,13 @@ static int process_event_synth_stub(union perf_event *event __used, ...@@ -277,6 +277,13 @@ static int process_event_synth_stub(union perf_event *event __used,
return 0; return 0;
} }
static int process_event_synth_attr_stub(union perf_event *event __used,
struct perf_evlist **pevlist __used)
{
dump_printf(": unhandled!\n");
return 0;
}
static int process_event_sample_stub(union perf_event *event __used, static int process_event_sample_stub(union perf_event *event __used,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -327,7 +334,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) ...@@ -327,7 +334,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
if (handler->unthrottle == NULL) if (handler->unthrottle == NULL)
handler->unthrottle = process_event_stub; handler->unthrottle = process_event_stub;
if (handler->attr == NULL) if (handler->attr == NULL)
handler->attr = process_event_synth_stub; handler->attr = process_event_synth_attr_stub;
if (handler->event_type == NULL) if (handler->event_type == NULL)
handler->event_type = process_event_synth_stub; handler->event_type = process_event_synth_stub;
if (handler->tracing_data == NULL) if (handler->tracing_data == NULL)
...@@ -794,12 +801,17 @@ static int perf_session__preprocess_sample(struct perf_session *session, ...@@ -794,12 +801,17 @@ static int perf_session__preprocess_sample(struct perf_session *session,
static int perf_session__process_user_event(struct perf_session *session, union perf_event *event, static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
struct perf_event_ops *ops, u64 file_offset) struct perf_event_ops *ops, u64 file_offset)
{ {
int err;
dump_event(session, event, file_offset, NULL); dump_event(session, event, file_offset, NULL);
/* These events are processed right away */ /* These events are processed right away */
switch (event->header.type) { switch (event->header.type) {
case PERF_RECORD_HEADER_ATTR: case PERF_RECORD_HEADER_ATTR:
return ops->attr(event, session); err = ops->attr(event, &session->evlist);
if (err == 0)
perf_session__update_sample_type(session);
return err;
case PERF_RECORD_HEADER_EVENT_TYPE: case PERF_RECORD_HEADER_EVENT_TYPE:
return ops->event_type(event, session); return ops->event_type(event, session);
case PERF_RECORD_HEADER_TRACING_DATA: case PERF_RECORD_HEADER_TRACING_DATA:
......
...@@ -63,6 +63,8 @@ typedef int (*event_op)(union perf_event *self, struct perf_sample *sample, ...@@ -63,6 +63,8 @@ typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
typedef int (*event_synth_op)(union perf_event *self, typedef int (*event_synth_op)(union perf_event *self,
struct perf_session *session); struct perf_session *session);
typedef int (*event_attr_op)(union perf_event *event,
struct perf_evlist **pevlist);
typedef int (*event_op2)(union perf_event *self, struct perf_session *session, typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
struct perf_event_ops *ops); struct perf_event_ops *ops);
...@@ -76,8 +78,8 @@ struct perf_event_ops { ...@@ -76,8 +78,8 @@ struct perf_event_ops {
read, read,
throttle, throttle,
unthrottle; unthrottle;
event_synth_op attr, event_attr_op attr;
event_type, event_synth_op event_type,
tracing_data, tracing_data,
build_id; build_id;
event_op2 finished_round; event_op2 finished_round;
......
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