Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242520
b: refs/heads/master
c: 9e69c21
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Mar 23, 2011
1 parent e7e731f commit 98a1332
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 47 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 880f57318450dbead6a03f9e31a1468924d6dd88
refs/heads/master: 9e69c210822c4035708a6111567c96364ca244d5
18 changes: 4 additions & 14 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ static const char *sym_hist_filter;

static int perf_evlist__add_sample(struct perf_evlist *evlist,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct addr_location *al)
{
struct perf_evsel *evsel;
struct hist_entry *he;
int ret;

Expand All @@ -59,18 +59,6 @@ static int perf_evlist__add_sample(struct perf_evlist *evlist,
return 0;
}

evsel = perf_evlist__id2evsel(evlist, sample->id);
if (evsel == NULL) {
/*
* FIXME: Propagate this back, but at least we're in a builtin,
* where exit() is allowed. ;-)
*/
ui__warning("Invalid %s file, contains samples with id not in "
"its header!\n", input_name);
exit_browser(0);
exit(1);
}

he = __hists__add_entry(&evsel->hists, al, NULL, 1);
if (he == NULL)
return -ENOMEM;
Expand All @@ -92,6 +80,7 @@ static int perf_evlist__add_sample(struct perf_evlist *evlist,

static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session)
{
struct addr_location al;
Expand All @@ -103,7 +92,8 @@ static int process_sample_event(union perf_event *event,
return -1;
}

if (!al.filtered && perf_evlist__add_sample(session->evlist, sample, &al)) {
if (!al.filtered &&
perf_evlist__add_sample(session->evlist, sample, evsel, &al)) {
pr_warning("problem incrementing symbol count, "
"skipping event\n");
return -1;
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static int hists__add_entry(struct hists *self,

static int diff__process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct addr_location al;
Expand Down
11 changes: 10 additions & 1 deletion trunk/tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ static int perf_event__repipe(union perf_event *event,
return perf_event__repipe_synth(event, session);
}

static int perf_event__repipe_sample(union perf_event *event,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
return perf_event__repipe_synth(event, session);
}

static int perf_event__repipe_mmap(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session)
Expand Down Expand Up @@ -124,6 +132,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)

static int perf_event__inject_buildid(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct addr_location al;
Expand Down Expand Up @@ -164,7 +173,7 @@ static int perf_event__inject_buildid(union perf_event *event,
}

struct perf_event_ops inject_ops = {
.sample = perf_event__repipe,
.sample = perf_event__repipe_sample,
.mmap = perf_event__repipe,
.comm = perf_event__repipe,
.fork = perf_event__repipe,
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,

static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, event->ip.pid);
Expand Down
4 changes: 3 additions & 1 deletion trunk/tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ static void dump_info(void)
die("Unknown type of information\n");
}

static int process_sample_event(union perf_event *event, struct perf_sample *sample,
static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *s)
{
struct thread *thread = perf_session__findnew(s, sample->tid);
Expand Down
19 changes: 4 additions & 15 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ static symbol_filter_t annotate_init;

static int perf_session__add_hist_entry(struct perf_session *session,
struct addr_location *al,
struct perf_sample *sample)
struct perf_sample *sample,
struct perf_evsel *evsel)
{
struct symbol *parent = NULL;
int err = 0;
struct hist_entry *he;
struct perf_evsel *evsel;

if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
err = perf_session__resolve_callchain(session, al->thread,
Expand All @@ -64,18 +64,6 @@ static int perf_session__add_hist_entry(struct perf_session *session,
return err;
}

evsel = perf_evlist__id2evsel(session->evlist, sample->id);
if (evsel == NULL) {
/*
* FIXME: Propagate this back, but at least we're in a builtin,
* where exit() is allowed. ;-)
*/
ui__warning("Invalid %s file, contains samples with id %" PRIu64 " not in "
"its header!\n", input_name, sample->id);
exit_browser(0);
exit(1);
}

he = __hists__add_entry(&evsel->hists, al, parent, sample->period);
if (he == NULL)
return -ENOMEM;
Expand Down Expand Up @@ -113,6 +101,7 @@ static int perf_session__add_hist_entry(struct perf_session *session,

static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session)
{
struct addr_location al;
Expand All @@ -127,7 +116,7 @@ static int process_sample_event(union perf_event *event,
if (al.filtered || (hide_unresolved && al.sym == NULL))
return 0;

if (perf_session__add_hist_entry(session, &al, sample)) {
if (perf_session__add_hist_entry(session, &al, sample, evsel)) {
pr_debug("problem incrementing symbol period, skipping event\n");
return -1;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ static void process_raw_event(union perf_event *raw_event __used,

static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct thread *thread;
Expand Down
15 changes: 4 additions & 11 deletions trunk/tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,11 @@ static void print_sample_start(struct perf_sample *sample,

static void process_event(union perf_event *event __unused,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session,
struct thread *thread)
{
struct perf_event_attr *attr;
struct perf_evsel *evsel;

evsel = perf_evlist__id2evsel(session->evlist, sample->id);
if (evsel == NULL) {
pr_err("Invalid data. Contains samples with id not in "
"its header!\n");
return;
}
attr = &evsel->attr;
struct perf_event_attr *attr = &evsel->attr;

if (output_fields[attr->type] == 0)
return;
Expand Down Expand Up @@ -244,6 +236,7 @@ static char const *input_name = "perf.data";

static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, event->ip.pid);
Expand All @@ -264,7 +257,7 @@ static int process_sample_event(union perf_event *event,
last_timestamp = sample->time;
return 0;
}
scripting_ops->process_event(event, sample, session, thread);
scripting_ops->process_event(event, sample, evsel, session, thread);

session->hists.stats.total_period += sample->period;
return 0;
Expand Down
11 changes: 11 additions & 0 deletions trunk/tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)

static int process_sample_event(union perf_event *event __used,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct trace_entry *te;
Expand All @@ -506,6 +507,16 @@ static int process_sample_event(union perf_event *event __used,
struct power_entry_old *peo;
peo = (void *)te;
#endif
/*
* FIXME: use evsel, its already mapped from id to perf_evsel,
* remove perf_header__find_event infrastructure bits.
* Mapping all these "power:cpu_idle" strings to the tracepoint
* ID and then just comparing against evsel->attr.config.
*
* e.g.:
*
* if (evsel->attr.config == power_cpu_idle_id)
*/
event_str = perf_header__find_event(te->type);

if (!event_str)
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/build-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

static int build_id__mark_dso_hit(union perf_event *event,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
struct perf_session *session)
{
struct addr_location al;
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct events_stats {
u32 nr_events[PERF_RECORD_HEADER_MAX];
u32 nr_unknown_events;
u32 nr_invalid_chains;
u32 nr_unknown_id;
};

enum hist_column {
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/scripting-engines/trace-event-perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ static inline struct event *find_cache_event(int type)

static void perl_process_event(union perf_event *pevent __unused,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session __unused,
struct thread *thread)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static inline struct event *find_cache_event(int type)

static void python_process_event(union perf_event *pevent __unused,
struct perf_sample *sample,
struct perf_evsel *evsel __unused,
struct perf_session *session __unused,
struct thread *thread)
{
Expand Down
25 changes: 23 additions & 2 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ static int process_event_synth_stub(union perf_event *event __used,
return 0;
}

static int process_event_sample_stub(union perf_event *event __used,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
struct perf_session *session __used)
{
dump_printf(": unhandled!\n");
return 0;
}

static int process_event_stub(union perf_event *event __used,
struct perf_sample *sample __used,
struct perf_session *session __used)
Expand All @@ -303,7 +312,7 @@ static int process_finished_round(union perf_event *event,
static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
{
if (handler->sample == NULL)
handler->sample = process_event_stub;
handler->sample = process_event_sample_stub;
if (handler->mmap == NULL)
handler->mmap = process_event_stub;
if (handler->comm == NULL)
Expand Down Expand Up @@ -698,12 +707,19 @@ static int perf_session_deliver_event(struct perf_session *session,
struct perf_event_ops *ops,
u64 file_offset)
{
struct perf_evsel *evsel;

dump_event(session, event, file_offset, sample);

switch (event->header.type) {
case PERF_RECORD_SAMPLE:
dump_sample(session, event, sample);
return ops->sample(event, sample, session);
evsel = perf_evlist__id2evsel(session->evlist, sample->id);
if (evsel == NULL) {
++session->hists.stats.nr_unknown_id;
return -1;
}
return ops->sample(event, sample, evsel, session);
case PERF_RECORD_MMAP:
return ops->mmap(event, sample, session);
case PERF_RECORD_COMM:
Expand Down Expand Up @@ -845,6 +861,11 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
session->hists.stats.nr_unknown_events);
}

if (session->hists.stats.nr_unknown_id != 0) {
ui__warning("%u samples with id not present in the header\n",
session->hists.stats.nr_unknown_id);
}

if (session->hists.stats.nr_invalid_chains != 0) {
ui__warning("Found invalid callchains!\n\n"
"%u out of %u events were discarded for this reason.\n\n"
Expand Down
7 changes: 5 additions & 2 deletions trunk/tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ struct perf_session {
char filename[0];
};

struct perf_evsel;
struct perf_event_ops;

typedef int (*event_sample)(union perf_event *event, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_session *session);
typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
struct perf_session *session);
typedef int (*event_synth_op)(union perf_event *self,
Expand All @@ -65,8 +68,8 @@ typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
struct perf_event_ops *ops);

struct perf_event_ops {
event_op sample,
mmap,
event_sample sample;
event_op mmap,
comm,
fork,
exit,
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/trace-event-scripting.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static int stop_script_unsupported(void)

static void process_event_unsupported(union perf_event *event __unused,
struct perf_sample *sample __unused,
struct perf_evsel *evsel __unused,
struct perf_session *session __unused,
struct thread *thread __unused)
{
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/trace-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ struct scripting_ops {
int (*stop_script) (void);
void (*process_event) (union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct perf_session *session,
struct thread *thread);
int (*generate_script) (const char *outfile);
Expand Down

0 comments on commit 98a1332

Please sign in to comment.