From 2a525f6a5502bfd80568e6befb84053cf650ad25 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Fri, 30 Apr 2021 10:03:01 +0300 Subject: 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 Reviewed-by: Andi Kleen Cc: Jiri Olsa Link: https://lore.kernel.org/r/20210430070309.17624-5-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/perf/util/header.c') diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index aa1e42518d37..02b13c7a23be 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3814,6 +3814,11 @@ int perf_session__read_header(struct perf_session *session) if (perf_file_header__read(&f_header, header, fd) < 0) return -EINVAL; + if (header->needs_swap && data->in_place_update) { + pr_err("In-place update not supported when byte-swapping is required\n"); + return -EINVAL; + } + /* * Sanity check that perf.data was written cleanly; data size is * initialized to 0 and updated only if the on_exit function is run. -- cgit v1.2.3