From fab4c1c4ab64389630db29093e66844186b536a6 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 4 Mar 2011 22:29:39 -0300 Subject: [PATCH] --- yaml --- r: 234510 b: refs/heads/master c: 3d3b5e95997208067c963923db90ed1517565d14 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/tools/perf/util/evlist.c | 28 ++++++++++++++++++---------- trunk/tools/perf/util/evlist.h | 3 +++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 3e3b29c59c0f..20f33ec14468 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 60098917c06d154d06ce030c125266eab9e60768 +refs/heads/master: 3d3b5e95997208067c963923db90ed1517565d14 diff --git a/trunk/tools/perf/util/evlist.c b/trunk/tools/perf/util/evlist.c index 030ae7f05e03..190c64c6e266 100644 --- a/trunk/tools/perf/util/evlist.c +++ b/trunk/tools/perf/util/evlist.c @@ -106,12 +106,24 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) evlist->nr_fds++; } -static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, - int cpu, int thread, int fd) +void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, + int cpu, int thread, u64 id) +{ + int hash; + struct perf_sample_id *sid = SID(evsel, cpu, thread); + + sid->id = id; + sid->evsel = evsel; + hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); + hlist_add_head(&sid->node, &evlist->heads[hash]); +} + +static int perf_evlist__id_hash_fd(struct perf_evlist *evlist, + struct perf_evsel *evsel, + int cpu, int thread, int fd) { - struct perf_sample_id *sid; u64 read_data[4] = { 0, }; - int hash, id_idx = 1; /* The first entry is the counter value */ + int id_idx = 1; /* The first entry is the counter value */ if (!(evsel->attr.read_format & PERF_FORMAT_ID) || read(fd, &read_data, sizeof(read_data)) == -1) @@ -122,11 +134,7 @@ static int perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *e if (evsel->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) ++id_idx; - sid = SID(evsel, cpu, thread); - sid->id = read_data[id_idx]; - sid->evsel = evsel; - hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); - hlist_add_head(&sid->node, &evlist->heads[hash]); + perf_evlist__id_hash(evlist, evsel, cpu, thread, read_data[id_idx]); return 0; } @@ -300,7 +308,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, int pages, bool overwrite) goto out_unmap; if ((evsel->attr.read_format & PERF_FORMAT_ID) && - perf_evlist__id_hash(evlist, evsel, cpu, thread, fd) < 0) + perf_evlist__id_hash_fd(evlist, evsel, cpu, thread, fd) < 0) goto out_unmap; } } diff --git a/trunk/tools/perf/util/evlist.h b/trunk/tools/perf/util/evlist.h index b75805aeb7e4..078d51256085 100644 --- a/trunk/tools/perf/util/evlist.h +++ b/trunk/tools/perf/util/evlist.h @@ -38,6 +38,9 @@ void perf_evlist__delete(struct perf_evlist *evlist); void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); int perf_evlist__add_default(struct perf_evlist *evlist); +void perf_evlist__id_hash(struct perf_evlist *evlist, struct perf_evsel *evsel, + int cpu, int thread, u64 id); + int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);