linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 45/76] perf evlist: Tidy duplicated munmap code
Date: Thu, 18 Jul 2013 16:49:32 -0300	[thread overview]
Message-ID: <1374177003-3706-46-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1374177003-3706-1-git-send-email-acme@infradead.org>

From: Adrian Hunter <adrian.hunter@intel.com>

The same lines of code are used in three places.  Make it a new function
'__perf_evlist__munmap()'.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1372944040-32690-8-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d8f34e0..42ea4e9 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -403,16 +403,20 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 	return event;
 }
 
+static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
+{
+	if (evlist->mmap[idx].base != NULL) {
+		munmap(evlist->mmap[idx].base, evlist->mmap_len);
+		evlist->mmap[idx].base = NULL;
+	}
+}
+
 void perf_evlist__munmap(struct perf_evlist *evlist)
 {
 	int i;
 
-	for (i = 0; i < evlist->nr_mmaps; i++) {
-		if (evlist->mmap[i].base != NULL) {
-			munmap(evlist->mmap[i].base, evlist->mmap_len);
-			evlist->mmap[i].base = NULL;
-		}
-	}
+	for (i = 0; i < evlist->nr_mmaps; i++)
+		__perf_evlist__munmap(evlist, i);
 
 	free(evlist->mmap);
 	evlist->mmap = NULL;
@@ -477,12 +481,8 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int m
 	return 0;
 
 out_unmap:
-	for (cpu = 0; cpu < nr_cpus; cpu++) {
-		if (evlist->mmap[cpu].base != NULL) {
-			munmap(evlist->mmap[cpu].base, evlist->mmap_len);
-			evlist->mmap[cpu].base = NULL;
-		}
-	}
+	for (cpu = 0; cpu < nr_cpus; cpu++)
+		__perf_evlist__munmap(evlist, cpu);
 	return -1;
 }
 
@@ -517,12 +517,8 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, in
 	return 0;
 
 out_unmap:
-	for (thread = 0; thread < nr_threads; thread++) {
-		if (evlist->mmap[thread].base != NULL) {
-			munmap(evlist->mmap[thread].base, evlist->mmap_len);
-			evlist->mmap[thread].base = NULL;
-		}
-	}
+	for (thread = 0; thread < nr_threads; thread++)
+		__perf_evlist__munmap(evlist, thread);
 	return -1;
 }
 
-- 
1.8.1.4


  parent reply	other threads:[~2013-07-18 19:59 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1374177003-3706-1-git-send-email-acme@infradead.org>
2013-07-18 19:48 ` [PATCH 01/76] perf tools: Rename cpu_map__all() to cpu_map__empty() Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 02/76] perf top: Add --objdump option Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 03/76] perf tools: Remove cwd from perf_session struct Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 04/76] perf tests: Omit end of the symbol check failure for test 1 Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 05/76] perf tests: Make TEST_ASSERT_VAL global Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 06/76] perf tools: Use default include path notation for libtraceevent headers Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 07/76] perf tools: Add methods for setting/retrieving priv element of thread struct Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 08/76] perf tools: Remove callchain_cursor_reset call Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 09/76] perf util: Move debugfs/tracing helper functions to util.c Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 10/76] perf util: Use evsel->name to get tracepoint_paths Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 11/76] perf tools: Do not elide parent symbol column Arnaldo Carvalho de Melo
2013-07-18 19:48 ` [PATCH 12/76] perf report: Fix perf_session__delete removal Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 13/76] perf tools: Make Power7 events available for perf Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 14/76] perf evlist: Fix use of uninitialized variable Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 15/76] perf tools: Don't free list head in parse_events__free_terms Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 16/76] perf tests: Make terms a stack variable in test_term Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 17/76] perf parse events: Demystify memory allocations Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 18/76] tools lib traceevent: Remove unused install targets Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 19/76] tools lib traceevent: Get rid of unused gui target Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 20/76] tools lib traceevent: Add const qualifier to string arguments Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 21/76] tools lib traceevent: Add trace_seq_reset() Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 22/76] tools lib traceevent: Add page_size field to pevent Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 23/76] tools lib traceevent: Port kbuffer parser routines Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 24/76] perf util: Save page size in a trace file to pevent Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 25/76] perf util: Save long size of traced system Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 26/76] perf util: Make file/host_bigendian variable local Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 27/76] perf util: Skip reading header_event file Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 28/76] perf util: Parse header_page to get proper long size Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 29/76] perf util: Get rid of unused header_page_* variables Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 30/76] perf script: Adopt latency_format variable Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 31/76] perf util: Rename read_*() functions in trace-event-info.c Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 32/76] perf util: No need to call read_trace_init() in tracing_data_header() Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 33/76] perf util: Remove unused enum and macro in trace-event.h Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 34/76] perf sched: Move struct perf_sched definition out of cmd_sched() Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 35/76] perf gtk/hists: Use GtkTreeStore instead of GtkListStore Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 36/76] perf gtk/hists: Add support for callchains Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 37/76] perf gtk/hists: Display callchain overhead also Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 38/76] perf gtk/hists: Make column headers resizable Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 39/76] perf gtk/hists: Add a double-click handler for callchains Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 40/76] perf gtk/hists: Set rules hint for the hist browser Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 41/76] perf inject: Remove unused parameter Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 42/76] perf tools: Fix missing tool parameter Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 43/76] perf inject: Add missing 'finished_round' Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 44/76] perf tools: Add const specifier to perf_pmu__find name parameter Arnaldo Carvalho de Melo
2013-07-18 19:49 ` Arnaldo Carvalho de Melo [this message]
2013-07-18 19:49 ` [PATCH 46/76] perf tools: Validate perf event header size Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 47/76] perf tools: struct thread has a tid not a pid Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 48/76] perf tools: Default to cpu// for events v5 Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 49/76] perf list: List kernel supplied event aliases Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 50/76] perf report/top: Add option to collapse undesired parts of call graph Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 51/76] perf tools: Add struct perf_hpp_fmt into hpp callbacks Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 52/76] perf tools: Centralize default columns init in perf_hpp__init Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 53/76] perf diff: Introducing diff_data object to hold files Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 54/76] perf diff: Switching the base hists to be pairs head Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 55/76] perf hists: Marking dummy hists entries Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 56/76] perf diff: Display data file info ahead of the diff output Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 57/76] perf diff: Move diff related columns into diff command Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 58/76] perf diff: Move columns into struct data__file Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 59/76] perf diff: Change diff command to work over multiple data files Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 60/76] perf diff: Update perf diff documentation for multiple data comparison Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 61/76] perf diff: Making compute functions static Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 62/76] perf diff: Add generic order option for compute sorting Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 63/76] perf tools: Move hist_entry__period_snprintf into stdio code Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 64/76] perf timechart: Use traceevent lib event-parse.h include Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 65/76] perf timechart: Remove event types framework only user Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 66/76] perf tools: Remove event types from perf data file Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 67/76] perf record: Remove event types pushing Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 68/76] perf tools: Remove event types framework completely Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 69/76] perf tools: Fix 'make tools/perf' Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 70/76] perf symbols: Do not apply symfs for an absolute vmlinux path Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 71/76] perf tests: Check proper prev_state size for sched_switch tp Arnaldo Carvalho de Melo
2013-07-18 19:49 ` [PATCH 72/76] perf session: Use session->fd instead of passing fd as argument Arnaldo Carvalho de Melo
2013-07-18 19:50 ` [PATCH 73/76] perf header: Remove data_offset seek as it's not needed Arnaldo Carvalho de Melo
2013-07-18 19:50 ` [PATCH 74/76] perf header: Remove attr_offset from perf_header Arnaldo Carvalho de Melo
2013-07-18 19:50 ` [PATCH 75/76] perf header: Introduce feat_offset into perf_header Arnaldo Carvalho de Melo
2013-07-18 19:50 ` [PATCH 76/76] perf header: Recognize version number for perf data file Arnaldo Carvalho de Melo

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=1374177003-3706-46-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).