Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223892
b: refs/heads/master
c: 640c03c
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 5, 2010
1 parent db59d35 commit 7b94498
Show file tree
Hide file tree
Showing 19 changed files with 237 additions and 193 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: c980d1091810df13f21aabbce545fd98f545bbf7
refs/heads/master: 640c03ce837fe8d4b56342aba376ea0da3960459
6 changes: 3 additions & 3 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
return hist_entry__inc_addr_samples(he, al->addr);
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct addr_location al;
struct sample_data data;

if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand Down
11 changes: 6 additions & 5 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM;
}

static int diff__process_sample_event(event_t *event, struct perf_session *session)
static int diff__process_sample_event(event_t *event,
struct sample_data *sample,
struct perf_session *session)
{
struct addr_location al;
struct sample_data data = { .period = 1, };

if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand All @@ -44,12 +45,12 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi
if (al.filtered || al.sym == NULL)
return 0;

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

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

Expand Down
39 changes: 24 additions & 15 deletions trunk/tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
static char const *input_name = "-";
static bool inject_build_ids;

static int event__repipe(event_t *event __used,
struct perf_session *session __used)
static int event__repipe_synth(event_t *event,
struct perf_session *session __used)
{
uint32_t size;
void *buf = event;
Expand All @@ -36,22 +36,30 @@ static int event__repipe(event_t *event __used,
return 0;
}

static int event__repipe_mmap(event_t *self, struct perf_session *session)
static int event__repipe(event_t *event, struct sample_data *sample __used,
struct perf_session *session)
{
return event__repipe_synth(event, session);
}

static int event__repipe_mmap(event_t *self, struct sample_data *sample,
struct perf_session *session)
{
int err;

err = event__process_mmap(self, session);
event__repipe(self, session);
err = event__process_mmap(self, sample, session);
event__repipe(self, sample, session);

return err;
}

static int event__repipe_task(event_t *self, struct perf_session *session)
static int event__repipe_task(event_t *self, struct sample_data *sample,
struct perf_session *session)
{
int err;

err = event__process_task(self, session);
event__repipe(self, session);
err = event__process_task(self, sample, session);
event__repipe(self, sample, session);

return err;
}
Expand All @@ -61,7 +69,7 @@ static int event__repipe_tracing_data(event_t *self,
{
int err;

event__repipe(self, session);
event__repipe_synth(self, session);
err = event__process_tracing_data(self, session);

return err;
Expand Down Expand Up @@ -111,7 +119,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
return 0;
}

static int event__inject_buildid(event_t *event, struct perf_session *session)
static int event__inject_buildid(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct addr_location al;
struct thread *thread;
Expand Down Expand Up @@ -146,7 +155,7 @@ static int event__inject_buildid(event_t *event, struct perf_session *session)
}

repipe:
event__repipe(event, session);
event__repipe(event, sample, session);
return 0;
}

Expand All @@ -160,10 +169,10 @@ struct perf_event_ops inject_ops = {
.read = event__repipe,
.throttle = event__repipe,
.unthrottle = event__repipe,
.attr = event__repipe,
.event_type = event__repipe,
.tracing_data = event__repipe,
.build_id = event__repipe,
.attr = event__repipe_synth,
.event_type = event__repipe_synth,
.tracing_data = event__repipe_synth,
.build_id = event__repipe_synth,
};

extern volatile int session_done;
Expand Down
21 changes: 5 additions & 16 deletions trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,11 @@ process_raw_event(event_t *raw_event __used, void *data,
}
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct sample_data data;
struct thread *thread;
struct thread *thread = perf_session__findnew(session, event->ip.pid);

memset(&data, 0, sizeof(data));
data.time = -1;
data.cpu = -1;
data.period = 1;

event__parse_sample(event, session->sample_type, &data);

dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
data.pid, data.tid, data.ip, data.period);

thread = perf_session__findnew(session, event->ip.pid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
Expand All @@ -328,8 +317,8 @@ static int process_sample_event(event_t *event, struct perf_session *session)

dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

process_raw_event(event, data.raw_data, data.cpu,
data.time, thread);
process_raw_event(event, sample->raw_data, sample->cpu,
sample->time, thread);

return 0;
}
Expand Down
12 changes: 4 additions & 8 deletions trunk/tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,22 +834,18 @@ static void dump_info(void)
die("Unknown type of information\n");
}

static int process_sample_event(event_t *self, struct perf_session *s)
static int process_sample_event(event_t *self, struct sample_data *sample,
struct perf_session *s)
{
struct sample_data data;
struct thread *thread;
struct thread *thread = perf_session__findnew(s, sample->tid);

bzero(&data, sizeof(data));
event__parse_sample(self, s->sample_type, &data);

thread = perf_session__findnew(s, data.tid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
self->header.type);
return -1;
}

process_raw_event(data.raw_data, data.cpu, data.time, thread);
process_raw_event(sample->raw_data, sample->cpu, sample->time, thread);

return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static int *fd[MAX_NR_CPUS][MAX_COUNTERS];

static u64 user_interval = ULLONG_MAX;
static u64 default_interval = 0;
static u64 sample_type;

static int nr_cpus = 0;
static unsigned int page_size;
Expand Down Expand Up @@ -129,6 +130,7 @@ static void write_output(void *buf, size_t size)
}

static int process_synthesized_event(event_t *event,
struct sample_data *sample __used,
struct perf_session *self __used)
{
write_output(event, event->header.size);
Expand Down Expand Up @@ -287,6 +289,9 @@ static void create_counter(int counter, int cpu)
attr->sample_type |= PERF_SAMPLE_CPU;
}

if (!sample_type)
sample_type = attr->sample_type;

attr->mmap = track;
attr->comm = track;
attr->inherit = !no_inherit;
Expand Down Expand Up @@ -642,6 +647,8 @@ static int __cmd_record(int argc, const char **argv)
open_counters(cpumap[i]);
}

perf_session__set_sample_type(session, sample_type);

if (pipe_output) {
err = perf_header__write_pipe(output);
if (err < 0)
Expand Down
15 changes: 8 additions & 7 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ static int add_event_total(struct perf_session *session,
return 0;
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct sample_data data = { .period = 1, };
struct addr_location al;
struct perf_event_attr *attr;

if (event__preprocess_sample(event, session, &al, &data, NULL) < 0) {
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type);
return -1;
Expand All @@ -165,22 +165,23 @@ static int process_sample_event(event_t *event, struct perf_session *session)
if (al.filtered || (hide_unresolved && al.sym == NULL))
return 0;

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

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

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

return 0;
}

static int process_read_event(event_t *event, struct perf_session *session __used)
static int process_read_event(event_t *event, struct sample_data *sample __used,
struct perf_session *session __used)
{
struct perf_event_attr *attr;

Expand Down
21 changes: 6 additions & 15 deletions trunk/tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,25 +1606,15 @@ process_raw_event(event_t *raw_event __used, struct perf_session *session,
process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread);
}

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct sample_data data;
struct thread *thread;

if (!(session->sample_type & PERF_SAMPLE_RAW))
return 0;

memset(&data, 0, sizeof(data));
data.time = -1;
data.cpu = -1;
data.period = -1;

event__parse_sample(event, session->sample_type, &data);

dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
data.pid, data.tid, data.ip, data.period);

thread = perf_session__findnew(session, data.pid);
thread = perf_session__findnew(session, sample->pid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
Expand All @@ -1633,10 +1623,11 @@ static int process_sample_event(event_t *event, struct perf_session *session)

dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

if (profile_cpu != -1 && profile_cpu != (int)data.cpu)
if (profile_cpu != -1 && profile_cpu != (int)sample->cpu)
return 0;

process_raw_event(event, session, data.raw_data, data.cpu, data.time, thread);
process_raw_event(event, session, sample->raw_data, sample->cpu,
sample->time, thread);

return 0;
}
Expand Down
34 changes: 12 additions & 22 deletions trunk/tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,11 @@ static int cleanup_scripting(void)

static char const *input_name = "perf.data";

static int process_sample_event(event_t *event, struct perf_session *session)
static int process_sample_event(event_t *event, struct sample_data *sample,
struct perf_session *session)
{
struct sample_data data;
struct thread *thread;
struct thread *thread = perf_session__findnew(session, event->ip.pid);

memset(&data, 0, sizeof(data));
data.time = -1;
data.cpu = -1;
data.period = 1;

event__parse_sample(event, session->sample_type, &data);

dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc,
data.pid, data.tid, data.ip, data.period);

thread = perf_session__findnew(session, event->ip.pid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
Expand All @@ -87,32 +76,33 @@ static int process_sample_event(event_t *event, struct perf_session *session)

if (session->sample_type & PERF_SAMPLE_RAW) {
if (debug_mode) {
if (data.time < last_timestamp) {
if (sample->time < last_timestamp) {
pr_err("Samples misordered, previous: %llu "
"this: %llu\n", last_timestamp,
data.time);
sample->time);
nr_unordered++;
}
last_timestamp = data.time;
last_timestamp = sample->time;
return 0;
}
/*
* FIXME: better resolve from pid from the struct trace_entry
* field, although it should be the same than this perf
* event pid
*/
scripting_ops->process_event(data.cpu, data.raw_data,
data.raw_size,
data.time, thread->comm);
scripting_ops->process_event(sample->cpu, sample->raw_data,
sample->raw_size,
sample->time, thread->comm);
}

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

static u64 nr_lost;

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

Expand Down
Loading

0 comments on commit 7b94498

Please sign in to comment.