Skip to content

Commit

Permalink
Merge branch 'perf' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…acme/linux-2.6 into perf/core
  • Loading branch information
Ingo Molnar committed May 15, 2010
2 parents 1ff3d7d + 3e1bbdc commit 7ebaa28
Show file tree
Hide file tree
Showing 18 changed files with 322 additions and 130 deletions.
2 changes: 2 additions & 0 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ LIB_H += util/thread.h
LIB_H += util/trace-event.h
LIB_H += util/probe-finder.h
LIB_H += util/probe-event.h
LIB_H += util/pstack.h
LIB_H += util/cpumap.h

LIB_OBJS += $(OUTPUT)util/abspath.o
Expand Down Expand Up @@ -451,6 +452,7 @@ LIB_OBJS += $(OUTPUT)util/callchain.o
LIB_OBJS += $(OUTPUT)util/values.o
LIB_OBJS += $(OUTPUT)util/debug.o
LIB_OBJS += $(OUTPUT)util/map.o
LIB_OBJS += $(OUTPUT)util/pstack.o
LIB_OBJS += $(OUTPUT)util/session.o
LIB_OBJS += $(OUTPUT)util/thread.o
LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ static int __cmd_annotate(void)
goto out_delete;

if (dump_trace) {
event__print_totals();
perf_session__fprintf_nr_events(session, stdout);
goto out_delete;
}

Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static bool force;
static bool show_displacement;

static int hists__add_entry(struct hists *self,
struct addr_location *al, u64 count)
struct addr_location *al, u64 period)
{
if (__hists__add_entry(self, al, NULL, count) != NULL)
if (__hists__add_entry(self, al, NULL, period) != NULL)
return 0;
return -ENOMEM;
}
Expand All @@ -50,11 +50,11 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
event__parse_sample(event, session->sample_type, &data);

if (hists__add_entry(&session->hists, &al, data.period)) {
pr_warning("problem incrementing symbol count, skipping event\n");
pr_warning("problem incrementing symbol period, skipping event\n");
return -1;
}

session->hists.stats.total += data.period;
session->hists.stats.total_period += data.period;
return 0;
}

Expand Down
44 changes: 31 additions & 13 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,14 @@ static int add_event_total(struct perf_session *session,
if (!hists)
return -ENOMEM;

hists->stats.total += data->period;
session->hists.stats.total += data->period;
hists->stats.total_period += data->period;
/*
* FIXME: add_event_total should be moved from here to
* perf_session__process_event so that the proper hist is passed to
* the event_op methods.
*/
hists__inc_nr_events(hists, PERF_RECORD_SAMPLE);
session->hists.stats.total_period += data->period;
return 0;
}

Expand Down Expand Up @@ -182,14 +188,14 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return 0;

if (perf_session__add_hist_entry(session, &al, &data)) {
pr_debug("problem incrementing symbol count, skipping event\n");
pr_debug("problem incrementing symbol period, skipping event\n");
return -1;
}

attr = perf_header__find_attr(data.id, &session->header);

if (add_event_total(session, &data, attr)) {
pr_debug("problem adding event count\n");
pr_debug("problem adding event period\n");
return -1;
}

Expand Down Expand Up @@ -263,11 +269,25 @@ static struct perf_event_ops event_ops = {

extern volatile int session_done;

static void sig_handler(int sig __attribute__((__unused__)))
static void sig_handler(int sig __used)
{
session_done = 1;
}

static size_t hists__fprintf_nr_sample_events(struct hists *self,
const char *evname, FILE *fp)
{
size_t ret;
char unit;
unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];

nr_events = convert_unit(nr_events, &unit);
ret = fprintf(fp, "# Events: %lu%c", nr_events, unit);
if (evname != NULL)
ret += fprintf(fp, " %s", evname);
return ret + fprintf(fp, "\n#\n");
}

static int __cmd_report(void)
{
int ret = -EINVAL;
Expand All @@ -293,7 +313,7 @@ static int __cmd_report(void)
goto out_delete;

if (dump_trace) {
event__print_totals();
perf_session__fprintf_nr_events(session, stdout);
goto out_delete;
}

Expand All @@ -313,14 +333,12 @@ static int __cmd_report(void)
if (use_browser)
hists__browse(hists, help, input_name);
else {
if (rb_first(&session->hists.entries) ==
const char *evname = NULL;
if (rb_first(&session->hists.entries) !=
rb_last(&session->hists.entries))
fprintf(stdout, "# Samples: %Ld\n#\n",
hists->stats.total);
else
fprintf(stdout, "# Samples: %Ld %s\n#\n",
hists->stats.total,
__event_name(hists->type, hists->config));
evname = __event_name(hists->type, hists->config);

hists__fprintf_nr_sample_events(hists, evname, stdout);

hists__fprintf(hists, NULL, false, stdout);
fprintf(stdout, "\n\n");
Expand Down
17 changes: 6 additions & 11 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,19 +1641,10 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return 0;
}

static int process_lost_event(event_t *event __used,
struct perf_session *session __used)
{
nr_lost_chunks++;
nr_lost_events += event->lost.lost;

return 0;
}

static struct perf_event_ops event_ops = {
.sample = process_sample_event,
.comm = event__process_comm,
.lost = process_lost_event,
.lost = event__process_lost,
.ordered_samples = true,
};

Expand All @@ -1664,8 +1655,12 @@ static int read_events(void)
if (session == NULL)
return -ENOMEM;

if (perf_session__has_traces(session, "record -R"))
if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops);
nr_events = session->hists.stats.nr_events[0];
nr_lost_events = session->hists.stats.total_lost;
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
}

perf_session__delete(session);
return err;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
data.time, thread->comm);
}

session->hists.stats.total += data.period;
session->hists.stats.total_period += data.period;
return 0;
}

Expand Down
19 changes: 18 additions & 1 deletion tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
#include "strlist.h"
#include "thread.h"

const char *event__name[] = {
[0] = "TOTAL",
[PERF_RECORD_MMAP] = "MMAP",
[PERF_RECORD_LOST] = "LOST",
[PERF_RECORD_COMM] = "COMM",
[PERF_RECORD_EXIT] = "EXIT",
[PERF_RECORD_THROTTLE] = "THROTTLE",
[PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
[PERF_RECORD_FORK] = "FORK",
[PERF_RECORD_READ] = "READ",
[PERF_RECORD_SAMPLE] = "SAMPLE",
[PERF_RECORD_HEADER_ATTR] = "ATTR",
[PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
[PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
[PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID",
};

static pid_t event__synthesize_comm(pid_t pid, int full,
event__handler_t process,
struct perf_session *session)
Expand Down Expand Up @@ -368,7 +385,7 @@ int event__process_comm(event_t *self, struct perf_session *session)
int event__process_lost(event_t *self, struct perf_session *session)
{
dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
session->hists.stats.lost += self->lost.lost;
session->hists.stats.total_lost += self->lost.lost;
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,6 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
struct addr_location *al, symbol_filter_t filter);
int event__parse_sample(event_t *event, u64 type, struct sample_data *data);

extern const char *event__name[];

#endif /* __PERF_RECORD_H */
Loading

0 comments on commit 7ebaa28

Please sign in to comment.