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, linux-perf-users@vger.kernel.org,
	Yisheng Xie <xieyisheng1@huawei.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/14] perf mmap: Discard head in overwrite_rb_find_range()
Date: Mon, 19 Mar 2018 16:01:28 -0300	[thread overview]
Message-ID: <20180319190136.7441-7-acme@kernel.org> (raw)
In-Reply-To: <20180319190136.7441-1-acme@kernel.org>

From: Yisheng Xie <xieyisheng1@huawei.com>

In overwrite mode, start will be set to head in perf_mmap__read_init().
Therefore, there is no need to set the start one more time in
overwrite_rb_find_range() and *start can be used as head instead of
passing head to overwrite_rb_find_range().

Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1520944274-37001-1-git-send-email-xieyisheng1@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/mmap.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 074c4fd3b67e..38ca3ffb9d61 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -199,19 +199,18 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
 	return 0;
 }
 
-static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end)
+static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end)
 {
 	struct perf_event_header *pheader;
-	u64 evt_head = head;
+	u64 evt_head = *start;
 	int size = mask + 1;
 
-	pr_debug2("overwrite_rb_find_range: buf=%p, head=%"PRIx64"\n", buf, head);
-	pheader = (struct perf_event_header *)(buf + (head & mask));
-	*start = head;
+	pr_debug2("%s: buf=%p, start=%"PRIx64"\n", __func__, buf, *start);
+	pheader = (struct perf_event_header *)(buf + (*start & mask));
 	while (true) {
-		if (evt_head - head >= (unsigned int)size) {
+		if (evt_head - *start >= (unsigned int)size) {
 			pr_debug("Finished reading overwrite ring buffer: rewind\n");
-			if (evt_head - head > (unsigned int)size)
+			if (evt_head - *start > (unsigned int)size)
 				evt_head -= pheader->size;
 			*end = evt_head;
 			return 0;
@@ -262,7 +261,7 @@ int perf_mmap__read_init(struct perf_mmap *md)
 		 * Backward ring buffer is full. We still have a chance to read
 		 * most of data from it.
 		 */
-		if (overwrite_rb_find_range(data, md->mask, head, &md->start, &md->end))
+		if (overwrite_rb_find_range(data, md->mask, &md->start, &md->end))
 			return -EINVAL;
 	}
 
-- 
2.14.3

  parent reply	other threads:[~2018-03-19 19:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 19:01 [GIT PULL 00/14] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 01/14] perf annotate: Use asprintf when formatting objdump command line Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 02/14] perf tests: Fix out of bounds access on array fd when cnt is 100 Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 03/14] perf record: Synthesize features before events in pipe mode Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 04/14] perf report: Support forced leader feature " Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 05/14] perf vendor events: Update POWER9 events Arnaldo Carvalho de Melo
2018-03-19 19:01 ` Arnaldo Carvalho de Melo [this message]
2018-03-19 19:01 ` [PATCH 07/14] perf debug: Avoid setting 'quiet' to 'true' unnecessarily Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 08/14] perf tools: Fix snprint warnings for gcc 8 Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 09/14] perf tools: Fix python extension build " Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 10/14] perf top: Document --ignore-vmlinux Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 11/14] perf annotate: Use ops->target.name when available for unresolved call targets Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 12/14] perf probe: Use right type to access array elements Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 13/14] objtool, perf: Fix GCC 8 -Wrestrict error Arnaldo Carvalho de Melo
2018-03-19 19:01 ` [PATCH 14/14] perf tests bp_account: Fix build with clang-6 Arnaldo Carvalho de Melo
2018-03-19 19:39 ` [GIT PULL 00/14] 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=20180319190136.7441-7-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=xieyisheng1@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).