From: Jiri Olsa <jolsa@redhat.com>
To: acme@redhat.com, a.p.zijlstra@chello.nl, mingo@elte.hu, paulus@samba.org
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 2/4] perf, tool: Factor evlist code to use global unmap function
Date: Fri, 9 Dec 2011 18:30:36 +0100 [thread overview]
Message-ID: <1323451838-23081-3-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1323451838-23081-1-git-send-email-jolsa@redhat.com>
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
next prev parent reply other threads:[~2011-12-09 17:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-09 17:30 [PATCH 0/4] perf tool: Refactoring IO mmap/data files code Jiri Olsa
2011-12-09 17:30 ` [PATCH 1/4] perf, tool: Centralize the memory maps handling Jiri Olsa
2011-12-09 17:30 ` Jiri Olsa [this message]
2011-12-09 17:30 ` [PATCH 3/4] perf, tool: Introducing perf_mmap object Jiri Olsa
2011-12-09 17:30 ` [PATCH 4/4] perf, tool: Introducing perf_data object Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323451838-23081-3-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®