aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2021-04-30 10:03:01 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-05-12 12:43:10 -0300
commit2a525f6a5502bfd80568e6befb84053cf650ad25 (patch)
tree6b2bdf6fbde7501965a097302c91545deb421bf2 /tools/perf/util/session.c
parentperf intel-pt: Support Z itrace option for timeless decoding (diff)
downloadlinux-dev-2a525f6a5502bfd80568e6befb84053cf650ad25.tar.xz
linux-dev-2a525f6a5502bfd80568e6befb84053cf650ad25.zip
perf inject: Add facility to do in place update
When there is a need to modify only timestamps, it is much simpler and quicker to do it to the existing file rather than re-write all the contents. In preparation for that, add the ability to modify the input file in place. In practice that just means making the file descriptor and mmaps writable. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/20210430070309.17624-5-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to '')
-rw-r--r--tools/perf/util/session.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 106b3d60881a..0dbb4f2628f3 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2155,6 +2155,7 @@ struct reader {
u64 data_size;
u64 data_offset;
reader_cb_t process;
+ bool in_place_update;
};
static int
@@ -2188,7 +2189,9 @@ reader__process_events(struct reader *rd, struct perf_session *session,
mmap_prot = PROT_READ;
mmap_flags = MAP_SHARED;
- if (session->header.needs_swap) {
+ if (rd->in_place_update) {
+ mmap_prot |= PROT_WRITE;
+ } else if (session->header.needs_swap) {
mmap_prot |= PROT_WRITE;
mmap_flags = MAP_PRIVATE;
}
@@ -2274,6 +2277,7 @@ static int __perf_session__process_events(struct perf_session *session)
.data_size = session->header.data_size,
.data_offset = session->header.data_offset,
.process = process_simple,
+ .in_place_update = session->data->in_place_update,
};
struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = session->tool;