• Adrian Hunter's avatar
    perf inject: Keep some features sections from input file · 180b3d06
    Adrian Hunter authored
    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: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20220520132404.25853-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    180b3d06
header.c 95.4 KB