All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Wang Nan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@redhat.com, acme@redhat.com, kan.liang@intel.com,
	mingo@kernel.org, namhyung@kernel.org, tglx@linutronix.de,
	hpa@zytor.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com
Subject: [tip:perf/core] perf mmap: Remove overwrite and check_messup from mmap read
Date: Wed, 6 Dec 2017 08:42:51 -0800	[thread overview]
Message-ID: <tip-8eb7a1fe31612fd3e8ae8042dd2ebaf7575504cb@git.kernel.org> (raw)
In-Reply-To: <20171203020044.81680-6-wangnan0@huawei.com>

Commit-ID:  8eb7a1fe31612fd3e8ae8042dd2ebaf7575504cb
Gitweb:     https://git.kernel.org/tip/8eb7a1fe31612fd3e8ae8042dd2ebaf7575504cb
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Sun, 3 Dec 2017 02:00:41 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 5 Dec 2017 15:43:54 -0300

perf mmap: Remove overwrite and check_messup from mmap read

All perf_mmap__read_forward() read from read-write ring buffer, so no
need check_messup. Reading from backward ring buffer doesn't require
check_messup because it never mess up. Cleanup arguments lists.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/20171203020044.81680-6-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c |  2 +-
 tools/perf/util/mmap.c   | 28 ++++------------------------
 tools/perf/util/mmap.h   |  2 +-
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index a59134f..68c1f95 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -711,7 +711,7 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
 	 * No need for read-write ring buffer: kernel stop outputting when
 	 * it hit md->prev (perf_mmap__consume()).
 	 */
-	return perf_mmap__read_forward(md, false);
+	return perf_mmap__read_forward(md);
 }
 
 union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 703ed41..3f262e7 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -21,33 +21,13 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map)
 }
 
 /* When check_messup is true, 'end' must points to a good entry */
-static union perf_event *perf_mmap__read(struct perf_mmap *map, bool check_messup,
+static union perf_event *perf_mmap__read(struct perf_mmap *map,
 					 u64 start, u64 end, u64 *prev)
 {
 	unsigned char *data = map->base + page_size;
 	union perf_event *event = NULL;
 	int diff = end - start;
 
-	if (check_messup) {
-		/*
-		 * If we're further behind than half the buffer, there's a chance
-		 * the writer will bite our tail and mess up the samples under us.
-		 *
-		 * If we somehow ended up ahead of the 'end', we got messed up.
-		 *
-		 * In either case, truncate and restart at 'end'.
-		 */
-		if (diff > map->mask / 2 || diff < 0) {
-			fprintf(stderr, "WARNING: failed to keep up with mmap data.\n");
-
-			/*
-			 * 'end' points to a known good entry, start there.
-			 */
-			start = end;
-			diff = 0;
-		}
-	}
-
 	if (diff >= (int)sizeof(event->header)) {
 		size_t size;
 
@@ -89,7 +69,7 @@ broken_event:
 	return event;
 }
 
-union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_messup)
+union perf_event *perf_mmap__read_forward(struct perf_mmap *map)
 {
 	u64 head;
 	u64 old = map->prev;
@@ -102,7 +82,7 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_mess
 
 	head = perf_mmap__read_head(map);
 
-	return perf_mmap__read(map, check_messup, old, head, &map->prev);
+	return perf_mmap__read(map, old, head, &map->prev);
 }
 
 union perf_event *perf_mmap__read_backward(struct perf_mmap *map)
@@ -138,7 +118,7 @@ union perf_event *perf_mmap__read_backward(struct perf_mmap *map)
 	else
 		end = head + map->mask + 1;
 
-	return perf_mmap__read(map, false, start, end, &map->prev);
+	return perf_mmap__read(map, start, end, &map->prev);
 }
 
 void perf_mmap__read_catchup(struct perf_mmap *map)
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index 2c3d291..d640273 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -86,7 +86,7 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail)
 	pc->data_tail = tail;
 }
 
-union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_messup);
+union perf_event *perf_mmap__read_forward(struct perf_mmap *map);
 union perf_event *perf_mmap__read_backward(struct perf_mmap *map);
 
 int perf_mmap__push(struct perf_mmap *md, bool backward,

  reply	other threads:[~2017-12-06 16:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-03  2:00 [PATCH v2 0/8] perf tools: perf tools: Clarify overwrite and backward, bugfix Wang Nan
2017-12-03  2:00 ` [PATCH v2 1/8] perf tools: Remove 'overwrite' parameter from perf_evlist__mmap Wang Nan
2017-12-06 16:41   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2017-12-03  2:00 ` [PATCH v2 2/8] perf tools: Remove 'overwrite' parameter from perf_evlist__mmap_ex Wang Nan
2017-12-06 16:41   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2017-12-03  2:00 ` [PATCH v2 3/8] perf tools: Remove evlist->overwrite Wang Nan
2017-12-06 16:42   ` [tip:perf/core] perf evlist: " tip-bot for Wang Nan
2017-12-03  2:00 ` [PATCH v2 4/8] perf tools: Remove overwrite from arguments list of perf_mmap__push Wang Nan
2017-12-06 16:42   ` [tip:perf/core] perf mmap: " tip-bot for Wang Nan
2017-12-03  2:00 ` [PATCH v2 5/8] perf tools: Remove overwrite and check_messup from mmap read Wang Nan
2017-12-06 16:42   ` tip-bot for Wang Nan [this message]
2017-12-03  2:00 ` [PATCH v2 6/8] perf mmap: Fix perf backward recording Wang Nan
2017-12-04  5:37   ` Namhyung Kim
2017-12-04 15:44     ` Arnaldo Carvalho de Melo
2017-12-03  2:00 ` [PATCH v2 7/8] perf tools: Don't discard prev in backward mode Wang Nan
2017-12-03  2:00 ` [PATCH v2 8/8] perf tools: Replace 'backward' to 'overwrite' in evlist, mmap and record Wang Nan
2017-12-04  5:39 ` [PATCH v2 0/8] perf tools: perf tools: Clarify overwrite and backward, bugfix Namhyung Kim

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=tip-8eb7a1fe31612fd3e8ae8042dd2ebaf7575504cb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.