mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: <linux-kernel@vger.kernel.org>, <kan.liang@intel.com>,
	<acme@kernel.org>, <jolsa@redhat.com>, <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 7/7] perf tools: Remove prot field in mmap param
Date: Mon, 13 Nov 2017 01:38:09 +0000	[thread overview]
Message-ID: <20171113013809.212417-8-wangnan0@huawei.com> (raw)
In-Reply-To: <20171113013809.212417-1-wangnan0@huawei.com>

After removing the concept of 'overwrite' in code level, now the
prot is determinated by write_backward. There's no need to pass
prot from perf_evlist__mmap_ex().

Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 tools/perf/util/evlist.c | 17 ++++++-----------
 tools/perf/util/mmap.c   |  4 ++--
 tools/perf/util/mmap.h   |  4 ++--
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 4948d3d..0d713e0 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -799,28 +799,23 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused,
 }
 
 static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
-				       struct mmap_params *_mp, int cpu_idx,
+				       struct mmap_params *mp, int cpu_idx,
 				       int thread, int *_output, int *_output_backward)
 {
 	struct perf_evsel *evsel;
 	int revent;
 	int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx);
-	struct mmap_params *mp;
 
 	evlist__for_each_entry(evlist, evsel) {
 		struct perf_mmap *maps = evlist->mmap;
-		struct mmap_params rdonly_mp;
 		int *output = _output;
 		int fd;
 		int cpu;
+		int prot = PROT_READ;
 
-		mp = _mp;
 		if (evsel->attr.write_backward) {
 			output = _output_backward;
 			maps = evlist->backward_mmap;
-			rdonly_mp = *_mp;
-			rdonly_mp.prot &= ~PROT_WRITE;
-			mp = &rdonly_mp;
 
 			if (!maps) {
 				maps = perf_evlist__alloc_mmap(evlist);
@@ -830,6 +825,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 				if (evlist->bkw_mmap_state == BKW_MMAP_NOTREADY)
 					perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_RUNNING);
 			}
+		} else {
+			prot |= PROT_WRITE;
 		}
 
 		if (evsel->system_wide && thread)
@@ -844,7 +841,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 		if (*output == -1) {
 			*output = fd;
 
-			if (perf_mmap__mmap(&maps[idx], mp, *output)  < 0)
+			if (perf_mmap__mmap(&maps[idx], mp, prot, *output)  < 0)
 				return -1;
 		} else {
 			if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
@@ -1064,9 +1061,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 	struct perf_evsel *evsel;
 	const struct cpu_map *cpus = evlist->cpus;
 	const struct thread_map *threads = evlist->threads;
-	struct mmap_params mp = {
-		.prot = PROT_READ | PROT_WRITE,
-	};
+	struct mmap_params mp;
 
 	if (!evlist->mmap)
 		evlist->mmap = perf_evlist__alloc_mmap(evlist);
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 703ed41..40e91a0 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -219,7 +219,7 @@ void perf_mmap__munmap(struct perf_mmap *map)
 	auxtrace_mmap__munmap(&map->auxtrace_mmap);
 }
 
-int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
+int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int prot, int fd)
 {
 	/*
 	 * The last one will be done at perf_evlist__mmap_consume(), so that we
@@ -237,7 +237,7 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
 	refcount_set(&map->refcnt, 2);
 	map->prev = 0;
 	map->mask = mp->mask;
-	map->base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot,
+	map->base = mmap(NULL, perf_mmap__mmap_len(map), prot,
 			 MAP_SHARED, fd, 0);
 	if (map->base == MAP_FAILED) {
 		pr_debug2("failed to mmap perf event ring buffer, error %d\n",
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index 2c3d291..1f6fcc6 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -53,11 +53,11 @@ enum bkw_mmap_state {
 };
 
 struct mmap_params {
-	int			    prot, mask;
+	int			    mask;
 	struct auxtrace_mmap_params auxtrace_mp;
 };
 
-int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd);
+int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int prot, int fd);
 void perf_mmap__munmap(struct perf_mmap *map);
 
 void perf_mmap__get(struct perf_mmap *map);
-- 
2.10.1

  parent reply	other threads:[~2017-11-13  1:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-13  1:38 [PATCH 0/7] perf tools: Clarify overwrite and backward, bugfix Wang Nan
2017-11-13  1:38 ` [PATCH 1/7] perf mmap: Fix perf backward recording Wang Nan
2017-11-13  1:38 ` [PATCH 2/7] perf tests: Set evlist of test__backward_ring_buffer() to !overwrite Wang Nan
2017-11-13 18:30   ` Arnaldo Carvalho de Melo
2017-11-18  8:30   ` [tip:perf/core] " tip-bot for Wang Nan
2017-11-13  1:38 ` [PATCH 3/7] perf tests: Set evlist of test__sw_clock_freq() " Wang Nan
2017-11-13 18:31   ` Arnaldo Carvalho de Melo
2017-11-18  8:30   ` [tip:perf/core] " tip-bot for Wang Nan
2017-11-13  1:38 ` [PATCH 4/7] perf tests: Set evlist of test__basic_mmap() " Wang Nan
2017-11-13 18:31   ` Arnaldo Carvalho de Melo
2017-11-18  8:31   ` [tip:perf/core] " tip-bot for Wang Nan
2017-11-13  1:38 ` [PATCH 5/7] perf tests: Set evlist of test__task_exit() " Wang Nan
2017-11-13 18:32   ` Arnaldo Carvalho de Melo
2017-11-18  8:31   ` [tip:perf/core] " tip-bot for Wang Nan
2017-11-13  1:38 ` [PATCH 6/7] perf tools: Remove 'overwrite' concept from code level Wang Nan
2017-11-13 11:52   ` Jiri Olsa
2017-11-13 15:07   ` Liang, Kan
2017-11-13  1:38 ` Wang Nan [this message]
2017-11-13 11:52   ` [PATCH 7/7] perf tools: Remove prot field in mmap param Jiri Olsa
2017-11-13 11:52   ` Jiri Olsa
2017-11-13 14:49 ` [PATCH 0/7] perf tools: Clarify overwrite and backward, bugfix Liang, Kan

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=20171113013809.212417-8-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.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®