linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Kan Liang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, wangnan0@huawei.com,
	tglx@linutronix.de, acme@redhat.com, mingo@kernel.org,
	namhyung@kernel.org, kan.liang@linux.intel.com, hpa@zytor.com,
	jolsa@kernel.org, ak@linux.intel.com
Subject: [tip:perf/core] perf mmap: Store mmap scope in struct perf_mmap()
Date: Fri, 9 Mar 2018 00:44:09 -0800	[thread overview]
Message-ID: <tip-4fda3459e3c2e5ca35d304646aeeb811242537b2@git.kernel.org> (raw)
In-Reply-To: <1520350567-80082-2-git-send-email-kan.liang@linux.intel.com>

Commit-ID:  4fda3459e3c2e5ca35d304646aeeb811242537b2
Gitweb:     https://git.kernel.org/tip/4fda3459e3c2e5ca35d304646aeeb811242537b2
Author:     Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Tue, 6 Mar 2018 10:36:01 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 8 Mar 2018 10:05:50 -0300

perf mmap: Store mmap scope in struct perf_mmap()

There is too much boilerplate in the perf_mmap__read*() interfaces.

The 'start' and 'end' variables should be stored in struct perf_mmap at
initialization. They will be used later.

The old 'startp' and 'endp' pointers are used by perf_mmap__read_event()
now.  They cannot be removed. So the old 'startp/endp' and new
'md->start/md->end' will exist simultaneously now.  The old one will be
removed later.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1520350567-80082-2-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/mmap.c | 12 ++++++++----
 tools/perf/util/mmap.h |  2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 4f27c464ce0b..09acaf7392bb 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -250,13 +250,15 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite,
 
 	*startp = overwrite ? head : old;
 	*endp = overwrite ? old : head;
+	md->start = md->overwrite ? head : old;
+	md->end = md->overwrite ? old : head;
 
-	if (*startp == *endp)
+	if (md->start == md->end)
 		return -EAGAIN;
 
-	size = *endp - *startp;
+	size = md->end - md->start;
 	if (size > (unsigned long)(md->mask) + 1) {
-		if (!overwrite) {
+		if (!md->overwrite) {
 			WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
 
 			md->prev = head;
@@ -268,8 +270,10 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite,
 		 * 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, startp, endp))
+		if (overwrite_rb_find_range(data, md->mask, head, &md->start, &md->end))
 			return -EINVAL;
+		*startp = md->start;
+		*endp = md->end;
 	}
 
 	return 0;
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index 71137977af28..9359e934ab14 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -20,6 +20,8 @@ struct perf_mmap {
 	int		 fd;
 	refcount_t	 refcnt;
 	u64		 prev;
+	u64		 start;
+	u64		 end;
 	bool		 overwrite;
 	struct auxtrace_mmap auxtrace_mmap;
 	char		 event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);

  reply	other threads:[~2018-03-09  8:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 15:36 [PATCH V2 1/8] perf evlist: Store 'overwrite' in struct perf_mmap kan.liang
2018-03-06 15:36 ` [PATCH V2 2/8] perf mmap: Store mmap scope " kan.liang
2018-03-09  8:44   ` tip-bot for Kan Liang [this message]
2018-03-06 15:36 ` [PATCH V2 3/8] perf mmap: Using the stored scope data in perf_mmap__push kan.liang
2018-03-09  8:44   ` [tip:perf/core] perf mmap: Use the stored scope data in perf_mmap__push() tip-bot for Kan Liang
2018-03-06 15:36 ` [PATCH V2 4/8] perf mmap: Using the stored data in perf_mmap__read_event kan.liang
2018-03-09  8:45   ` [tip:perf/core] perf mmap: Use the stored data in perf_mmap__read_event() tip-bot for Kan Liang
2018-03-06 15:36 ` [PATCH V2 5/8] perf mmap: Using stored 'overwrite' in perf_mmap__consume kan.liang
2018-03-09  8:45   ` [tip:perf/core] perf mmap: Use stored 'overwrite' in perf_mmap__consume() tip-bot for Kan Liang
2018-03-06 15:36 ` [PATCH V2 6/8] perf tools: Refine perf_mmap__consume kan.liang
2018-03-09  8:46   ` [tip:perf/core] perf mmap: Simplify perf_mmap__consume() tip-bot for Kan Liang
2018-03-06 15:36 ` [PATCH V2 7/8] perf tools: Refine perf_mmap__read_event kan.liang
2018-03-09  8:46   ` [tip:perf/core] perf mmap: Simplify perf_mmap__read_event() tip-bot for Kan Liang
2018-03-06 15:36 ` [PATCH V2 8/8] perf tools: Refine perf_mmap__read_init kan.liang
2018-03-09  8:46   ` [tip:perf/core] perf mmap: Simplify perf_mmap__read_init() tip-bot for Kan Liang
2018-03-07 10:12 ` [PATCH V2 1/8] perf evlist: Store 'overwrite' in struct perf_mmap Jiri Olsa
2018-03-09  8:43 ` [tip:perf/core] " tip-bot for Kan Liang

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-4fda3459e3c2e5ca35d304646aeeb811242537b2@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.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 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).