lkml.org 
[lkml]   [2011]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/4] perf, tool: Factor evlist code to use global unmap function
Date
Using __perf_evlist__munmap in case of map failure rather
than duplicate the unmap code.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/util/evlist.c | 20 +++++++-------------
1 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index f3178bc..56f1d34 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -416,7 +416,7 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
return event;
}

-void perf_evlist__munmap(struct perf_evlist *evlist)
+static void __perf_evlist__munmap(struct perf_evlist *evlist)
{
int i;

@@ -426,7 +426,11 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
evlist->mmap[i].base = NULL;
}
}
+}

+void perf_evlist__munmap(struct perf_evlist *evlist)
+{
+ __perf_evlist__munmap(evlist);
free(evlist->mmap);
evlist->mmap = NULL;
}
@@ -494,12 +498,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist)
return 0;

out_unmap:
- for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
- if (evlist->mmap[cpu].base != NULL) {
- munmap(evlist->mmap[cpu].base, evlist->mmap_len);
- evlist->mmap[cpu].base = NULL;
- }
- }
+ __perf_evlist__munmap(evlist);
return -1;
}

@@ -533,12 +532,7 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist)
return 0;

out_unmap:
- for (thread = 0; thread < evlist->threads->nr; thread++) {
- if (evlist->mmap[thread].base != NULL) {
- munmap(evlist->mmap[thread].base, evlist->mmap_len);
- evlist->mmap[thread].base = NULL;
- }
- }
+ __perf_evlist__munmap(evlist);
return -1;
}

--
1.7.4


\
 
 \ /
  Last update: 2011-12-09 18:33    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site