diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2022-05-20 16:24:02 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-05-23 10:11:25 -0300 |
commit | 180b3d06263ce70dd0622681237cf5c0555d9ca0 (patch) | |
tree | 6e88610849ac0c223c75d16b8a75e0e920b42beb /tools/perf/util/header.c | |
parent | 618ee7838e409513635320ca9c4c8d52c44f2dd0 (diff) | |
download | linux-180b3d06263ce70dd0622681237cf5c0555d9ca0.tar.gz linux-180b3d06263ce70dd0622681237cf5c0555d9ca0.tar.bz2 linux-180b3d06263ce70dd0622681237cf5c0555d9ca0.zip |
perf inject: Keep some features sections from input file
perf inject overwrites feature sections with information from the current
machine. It makes more sense to keep original information that describes
the machine or software when perf record was run.
Example: perf.data from "Desktop" injected on "nuc11"
Before:
$ perf script --header-only -i perf.data-from-desktop | head -15
# ========
# captured on : Thu May 19 09:55:50 2022
# header version : 1
# data offset : 1208
# data size : 837480
# feat offset : 838688
# hostname : Desktop
# os release : 5.13.0-41-generic
# perf version : 5.18.rc5.gac837f7ca7ed
# arch : x86_64
# nrcpus online : 28
# nrcpus avail : 28
# cpudesc : Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz
# cpuid : GenuineIntel,6,85,4
# total memory : 65548656 kB
$ perf inject -i perf.data-from-desktop -o injected-perf.data
$ perf script --header-only -i injected-perf.data | head -15
# ========
# captured on : Fri May 20 15:06:55 2022
# header version : 1
# data offset : 1208
# data size : 837480
# feat offset : 838688
# hostname : nuc11
# os release : 5.17.5-local
# perf version : 5.18.rc5.g0f828fdeb9af
# arch : x86_64
# nrcpus online : 8
# nrcpus avail : 8
# cpudesc : 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
# cpuid : GenuineIntel,6,140,1
# total memory : 16012124 kB
After:
$ perf inject -i perf.data-from-desktop -o injected-perf.data
$ perf script --header-only -i injected-perf.data | head -15
# ========
# captured on : Fri May 20 15:08:54 2022
# header version : 1
# data offset : 1208
# data size : 837480
# feat offset : 838688
# hostname : Desktop
# os release : 5.13.0-41-generic
# perf version : 5.18.rc5.gac837f7ca7ed
# arch : x86_64
# nrcpus online : 28
# nrcpus avail : 28
# cpudesc : Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz
# cpuid : GenuineIntel,6,85,4
# total memory : 65548656 kB
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220520132404.25853-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index b0c57a130d1e..53332da100e8 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3686,6 +3686,14 @@ int perf_session__write_header(struct perf_session *session, return perf_session__do_write_header(session, evlist, fd, at_exit, NULL); } +int perf_session__inject_header(struct perf_session *session, + struct evlist *evlist, + int fd, + struct feat_copier *fc) +{ + return perf_session__do_write_header(session, evlist, fd, true, fc); +} + static int perf_header__getbuffer64(struct perf_header *header, int fd, void *buf, size_t size) { |