Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257027
b: refs/heads/master
c: c2a7065
h: refs/heads/master
i:
  257025: eb3c255
  257023: a14972c
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jun 2, 2011
1 parent 9f586b5 commit 7564e81
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 45 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: 5c6970af2f4be4e04b06fe78214f6809777a8354
refs/heads/master: c2a70653af45c9cbb0cab900e8931b062e57b1ae
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ static int test__basic_mmap(void)
unsigned int nr_events[nsyscalls],
expected_nr_events[nsyscalls], i, j;
struct perf_evsel *evsels[nsyscalls], *evsel;
int sample_size = perf_sample_size(attr.sample_type);
int sample_size = __perf_evsel__sample_size(attr.sample_type);

for (i = 0; i < nsyscalls; ++i) {
char name[64];
Expand Down
16 changes: 0 additions & 16 deletions trunk/tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ const char *perf_event__name(unsigned int id)
return perf_event__names[id];
}

int perf_sample_size(u64 sample_type)
{
u64 mask = sample_type & PERF_SAMPLE_MASK;
int size = 0;
int i;

for (i = 0; i < 64; i++) {
if (mask & (1ULL << i))
size++;
}

size *= sizeof(u64);

return size;
}

static struct perf_sample synth_sample = {
.pid = -1,
.tid = -1,
Expand Down
2 changes: 0 additions & 2 deletions trunk/tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ struct perf_sample {
struct ip_callchain *callchain;
};

int perf_sample_size(u64 sample_type);

#define BUILD_ID_SIZE 20

struct build_id_event {
Expand Down
55 changes: 34 additions & 21 deletions trunk/tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,33 +455,46 @@ int perf_evlist__set_filters(struct perf_evlist *evlist)
return 0;
}

u64 perf_evlist__sample_type(struct perf_evlist *evlist)
bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist)
{
struct perf_evsel *pos;
u64 type = 0;

list_for_each_entry(pos, &evlist->entries, node) {
if (!type)
type = pos->attr.sample_type;
else if (type != pos->attr.sample_type)
die("non matching sample_type");
struct perf_evsel *pos, *first;

pos = first = list_entry(evlist->entries.next, struct perf_evsel, node);

list_for_each_entry_continue(pos, &evlist->entries, node) {
if (first->attr.sample_type != pos->attr.sample_type)
return false;
}

return type;
return true;
}

bool perf_evlist__sample_id_all(const struct perf_evlist *evlist)
u64 perf_evlist__sample_type(const struct perf_evlist *evlist)
{
struct perf_evsel *first;

first = list_entry(evlist->entries.next, struct perf_evsel, node);
return first->attr.sample_type;
}

bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist)
{
bool value = false, first = true;
struct perf_evsel *pos;

list_for_each_entry(pos, &evlist->entries, node) {
if (first) {
value = pos->attr.sample_id_all;
first = false;
} else if (value != pos->attr.sample_id_all)
die("non matching sample_id_all");
struct perf_evsel *pos, *first;

pos = first = list_entry(evlist->entries.next, struct perf_evsel, node);

list_for_each_entry_continue(pos, &evlist->entries, node) {
if (first->attr.sample_id_all != pos->attr.sample_id_all)
return false;
}

return value;
return true;
}

bool perf_evlist__sample_id_all(const struct perf_evlist *evlist)
{
struct perf_evsel *first;

first = list_entry(evlist->entries.next, struct perf_evsel, node);
return first->attr.sample_id_all;
}
6 changes: 4 additions & 2 deletions trunk/tools/perf/util/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid,
void perf_evlist__delete_maps(struct perf_evlist *evlist);
int perf_evlist__set_filters(struct perf_evlist *evlist);

u64 perf_evlist__sample_type(struct perf_evlist *evlist);
bool perf_evlist__sample_id_all(const struct perf_evlist *evlist);
u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);

bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
#endif /* __PERF_EVLIST_H */
16 changes: 16 additions & 0 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@

#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))

int __perf_evsel__sample_size(u64 sample_type)
{
u64 mask = sample_type & PERF_SAMPLE_MASK;
int size = 0;
int i;

for (i = 0; i < 64; i++) {
if (mask & (1ULL << i))
size++;
}

size *= sizeof(u64);

return size;
}

void perf_evsel__init(struct perf_evsel *evsel,
struct perf_event_attr *attr, int idx)
{
Expand Down
7 changes: 7 additions & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,11 @@ static inline int perf_evsel__read_scaled(struct perf_evsel *evsel,
return __perf_evsel__read(evsel, ncpus, nthreads, true);
}

int __perf_evsel__sample_size(u64 sample_type);

static inline int perf_evsel__sample_size(struct perf_evsel *evsel)
{
return __perf_evsel__sample_size(evsel->attr.sample_type);
}

#endif /* __PERF_EVSEL_H */
2 changes: 1 addition & 1 deletion trunk/tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,

first = list_entry(evlist->entries.next, struct perf_evsel, node);
err = perf_event__parse_sample(event, first->attr.sample_type,
perf_sample_size(first->attr.sample_type),
perf_evsel__sample_size(first),
sample_id_all, &pevent->sample);
if (err)
return PyErr_Format(PyExc_OSError,
Expand Down
12 changes: 11 additions & 1 deletion trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ static int perf_session__open(struct perf_session *self, bool force)
goto out_close;
}

if (!perf_evlist__valid_sample_type(self->evlist)) {
pr_err("non matching sample_type");
goto out_close;
}

if (!perf_evlist__valid_sample_id_all(self->evlist)) {
pr_err("non matching sample_id_all");
goto out_close;
}

self->size = input_stat.st_size;
return 0;

Expand Down Expand Up @@ -97,7 +107,7 @@ static void perf_session__id_header_size(struct perf_session *session)
void perf_session__update_sample_type(struct perf_session *self)
{
self->sample_type = perf_evlist__sample_type(self->evlist);
self->sample_size = perf_sample_size(self->sample_type);
self->sample_size = __perf_evsel__sample_size(self->sample_type);
self->sample_id_all = perf_evlist__sample_id_all(self->evlist);
perf_session__id_header_size(self);
}
Expand Down

0 comments on commit 7564e81

Please sign in to comment.