From: Wang Nan <wangnan0@huawei.com>
To: <acme@kernel.org>, <lizefan@huawei.com>
Cc: <linux-kernel@vger.kernel.org>, <pi3orama@163.com>,
<jolsa@redhat.com>, Wang Nan <wangnan0@huawei.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Nilay Vaish <nilayvaish@gmail.com>
Subject: [PATCH v15 05/12] perf tools: Extract common code in mmap failure processing
Date: Tue, 12 Jul 2016 10:00:05 +0000 [thread overview]
Message-ID: <1468317612-11598-6-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1468317612-11598-1-git-send-email-wangnan0@huawei.com>
In perf_evlist__mmap_per_cpu() and perf_evlist__mmap_per_thread(), when
mmap failure, successfully created maps should be cleared.
Current code uses two loops __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>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: pi3orama@163.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 6db4b7b..bbad72f 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);
@@ -959,12 +958,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;
@@ -972,8 +966,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);
}
@@ -1131,8 +1129,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;
}
@@ -1157,8 +1154,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;
}
--
1.8.3.4
next prev parent reply other threads:[~2016-07-12 10:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 10:00 [PATCH v15 00/12] perf tools: Support overwritable ring buffer Wang Nan
2016-07-12 10:00 ` [PATCH v15 01/12] perf tools: Drop redundant evsel->overwrite indicator Wang Nan
2016-07-12 10:00 ` [PATCH v15 02/12] tools lib fd array: Allow associating a pointer cookie with each entry Wang Nan
2016-07-12 10:00 ` [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers Wang Nan
2016-07-13 14:06 ` Jiri Olsa
2016-07-14 1:58 ` Wangnan (F)
2016-07-12 10:00 ` [PATCH v15 04/12] perf tools: Record mmap cookie into fdarray private field Wang Nan
2016-07-12 10:00 ` Wang Nan [this message]
2016-07-12 10:00 ` [PATCH v15 06/12] perf tools: Alloc backward_mmap array for evlist Wang Nan
2016-07-12 10:00 ` [PATCH v15 07/12] perf tools: Map backward events to backward_mmap Wang Nan
2016-07-13 14:06 ` Jiri Olsa
2016-07-12 10:00 ` [PATCH v15 08/12] perf tools: Drop evlist->backward Wang Nan
2016-07-12 10:00 ` [PATCH v15 09/12] perf record: Read from overwritable ring buffer Wang Nan
2016-07-13 14:06 ` Jiri Olsa
2016-07-13 14:07 ` Jiri Olsa
2016-07-13 14:07 ` Jiri Olsa
2016-07-12 10:00 ` [PATCH v15 10/12] perf tools: Enable overwrite settings Wang Nan
2016-07-12 10:00 ` [PATCH v15 11/12] perf tools: Don't warn about out of order event if write_backward is used Wang Nan
2016-07-12 10:00 ` [PATCH v15 12/12] perf tools: Add --tail-synthesize option Wang Nan
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=1468317612-11598-6-git-send-email-wangnan0@huawei.com \
--to=wangnan0@huawei.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=nilayvaish@gmail.com \
--cc=pi3orama@163.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).