linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Wang Nan <wangnan0@huawei.com>,
	He Kuang <hekuang@huawei.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Nilay Vaish <nilayvaish@gmail.com>, Zefan Li <lizefan@huawei.com>,
	pi3orama@163.com, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 13/24] perf evlist: Extract common code in mmap failure processing
Date: Fri, 15 Jul 2016 17:50:47 -0300	[thread overview]
Message-ID: <1468615858-24936-14-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1468615858-24936-1-git-send-email-acme@kernel.org>

From: Wang Nan <wangnan0@huawei.com>

In perf_evlist__mmap_per_cpu() and perf_evlist__mmap_per_thread(), in
case of mmap failure, successfully created maps should be cleared.

Current code uses two loops calling __perf_evlist__munmap() for each
function.

This patch extracts common code to perf_evlist__munmap_nofree() and use
previous introduced decoupled API perf_mmap__munmap(). Now
__perf_evlist__munmap() can be removed because of no user.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468485287-33422-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 1462085a8618..54ae0a0bc22c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -28,7 +28,6 @@
 #include <linux/err.h>
 
 static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx);
-static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx);
 static void perf_mmap__munmap(struct perf_mmap *map);
 static void perf_mmap__put(struct perf_mmap *map);
 
@@ -970,12 +969,7 @@ static void perf_mmap__munmap(struct perf_mmap *map)
 	auxtrace_mmap__munmap(&map->auxtrace_mmap);
 }
 
-static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
-{
-	perf_mmap__munmap(&evlist->mmap[idx]);
-}
-
-void perf_evlist__munmap(struct perf_evlist *evlist)
+static void perf_evlist__munmap_nofree(struct perf_evlist *evlist)
 {
 	int i;
 
@@ -983,8 +977,12 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
 		return;
 
 	for (i = 0; i < evlist->nr_mmaps; i++)
-		__perf_evlist__munmap(evlist, i);
+		perf_mmap__munmap(&evlist->mmap[i]);
+}
 
+void perf_evlist__munmap(struct perf_evlist *evlist)
+{
+	perf_evlist__munmap_nofree(evlist);
 	zfree(&evlist->mmap);
 }
 
@@ -1142,8 +1140,7 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist,
 	return 0;
 
 out_unmap:
-	for (cpu = 0; cpu < nr_cpus; cpu++)
-		__perf_evlist__munmap(evlist, cpu);
+	perf_evlist__munmap_nofree(evlist);
 	return -1;
 }
 
@@ -1168,8 +1165,7 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist,
 	return 0;
 
 out_unmap:
-	for (thread = 0; thread < nr_threads; thread++)
-		__perf_evlist__munmap(evlist, thread);
+	perf_evlist__munmap_nofree(evlist);
 	return -1;
 }
 
-- 
2.7.4

  parent reply	other threads:[~2016-07-15 20:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15 20:50 [GIT PULL 00/24] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 01/24] tools lib traceevent: Add correct header for ipv6 definitions Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 02/24] perf tools: Do not provide dup sched_getcpu() prototype on Android Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 03/24] tools: Make "__always_inline" just "inline" " Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 04/24] perf tools: Just pr_debug() about not being able to read cacheline_size Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 05/24] perf tools: Bail out at "--sort dcacheline" and cacheline_size not known Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 06/24] tools lib api fs: Use base 0 in filename__read_ull Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 07/24] perf evlist: Drop redundant evsel->overwrite indicator Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 08/24] tools: Simplify BITS_PER_LONG define Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 09/24] tools lib fd array: Allow associating a pointer cookie with each entry Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 10/24] perf evlist: Update mmap related APIs and helpers Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 11/24] perf record: Decouple record__mmap_read() and evlist Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 12/24] perf evlist: Record mmap cookie into fdarray private field Arnaldo Carvalho de Melo
2016-07-15 20:50 ` Arnaldo Carvalho de Melo [this message]
2016-07-15 20:50 ` [PATCH 14/24] perf evlist: Introduce backward_mmap array for evlist Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 15/24] perf evlist: Map backward events to backward_mmap Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 16/24] perf evlist: Drop evlist->backward Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 17/24] perf evlist: Setup backward mmap state machine Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 18/24] perf record: Read from overwritable ring buffer Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 19/24] perf evlist: Make {pause,resume} internal helpers Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 20/24] perf tools: Enable overwrite settings Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 21/24] perf session: Don't warn about out of order event if write_backward is used Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 22/24] perf record: Add --tail-synthesize option Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 23/24] objtool: Add -I$(srctree)/tools/arch/$(ARCH)/include/uapi Arnaldo Carvalho de Melo
2016-07-15 20:50 ` [PATCH 24/24] objtool: Initialize variable to silence old compiler Arnaldo Carvalho de Melo
2016-07-16 20:39 ` [GIT PULL 00/24] perf/core improvements and fixes Ingo Molnar

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=1468615858-24936-14-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=nilayvaish@gmail.com \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /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).