All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Andi Kleen <ak@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH V2 06/12] perf auxtrace: Allow buffers to be mapped read / write
Date: Fri, 30 Apr 2021 10:03:03 +0300	[thread overview]
Message-ID: <20210430070309.17624-7-adrian.hunter@intel.com> (raw)
In-Reply-To: <20210430070309.17624-1-adrian.hunter@intel.com>

To support in-place update, allow buffers to be mapped read / write.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/auxtrace.c | 5 +++--
 tools/perf/util/auxtrace.h | 6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 48b88e2bca1e..ade655d58780 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1120,8 +1120,9 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events)
 					 auxtrace_queue_data_cb, &qd);
 }
 
-void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
+void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw)
 {
+	int prot = rw ? PROT_READ | PROT_WRITE : PROT_READ;
 	size_t adj = buffer->data_offset & (page_size - 1);
 	size_t size = buffer->size + adj;
 	off_t file_offset = buffer->data_offset - adj;
@@ -1130,7 +1131,7 @@ void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
 	if (buffer->data)
 		return buffer->data;
 
-	addr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, file_offset);
+	addr = mmap(NULL, size, prot, MAP_SHARED, fd, file_offset);
 	if (addr == MAP_FAILED)
 		return NULL;
 
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 9ac2ac1bd793..472c0973b1f1 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -533,7 +533,11 @@ int auxtrace_queue_data(struct perf_session *session, bool samples,
 			bool events);
 struct auxtrace_buffer *auxtrace_buffer__next(struct auxtrace_queue *queue,
 					      struct auxtrace_buffer *buffer);
-void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd);
+void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw);
+static inline void *auxtrace_buffer__get_data(struct auxtrace_buffer *buffer, int fd)
+{
+	return auxtrace_buffer__get_data_rw(buffer, fd, false);
+}
 void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer);
 void auxtrace_buffer__drop_data(struct auxtrace_buffer *buffer);
 void auxtrace_buffer__free(struct auxtrace_buffer *buffer);
-- 
2.25.1


  parent reply	other threads:[~2021-04-30  7:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30  7:02 [PATCH V2 00/12] perf intel-pt: Add more support for VMs Adrian Hunter
2021-04-30  7:02 ` [PATCH V2 01/12] perf auxtrace: Add Z itrace option for timeless decoding Adrian Hunter
2021-04-30  7:02 ` [PATCH V2 02/12] perf intel-pt: Move synth_opts initialization earlier Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 03/12] perf intel-pt: Support Z itrace option for timeless decoding Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 04/12] perf inject: Add facility to do in place update Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 05/12] perf inject: Add --vm-time-correlation option Adrian Hunter
2021-04-30  7:03 ` Adrian Hunter [this message]
2021-04-30  7:03 ` [PATCH V2 07/12] perf intel-pt: Let overlap detection handle VM timestamps Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 08/12] perf intel-pt: Add a tree for VMCS information Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 09/12] perf intel-pt: Pass the first timestamp to the decoder Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 10/12] perf intel-pt: Better 7-byte timestamp wraparound logic Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 11/12] perf intel-pt: Add VM Time Correlation to decoder Adrian Hunter
2021-04-30  7:03 ` [PATCH V2 12/12] perf intel-pt: Parse VM Time Correlation options and set up decoding Adrian Hunter
2021-04-30 21:29 ` [PATCH V2 00/12] perf intel-pt: Add more support for VMs Andi Kleen
2021-05-03 15:09   ` Arnaldo Carvalho de Melo

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=20210430070309.17624-7-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.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 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.