perf tools: Factor out evsel__id_hdr_size()
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 11 Jul 2022 09:31:48 +0000 (12:31 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 Jul 2022 14:07:48 +0000 (11:07 -0300)
commit0a64de04c94ad4285120bed0dfb382ea98d6d499
tree571a8a6c3b4f8f5eb2c8efe8610ca4e1ea1d7244
parenteddc6e3f6684597924f368cb564d7432b2f7d23e
perf tools: Factor out evsel__id_hdr_size()

Factor out evsel__id_hdr_size() so it can be reused.

This is needed by perf inject. When injecting events from a guest perf.data
file, there is a possibility that the sample ID numbers conflict. To
re-write an ID sample, the old one needs to be removed first, which means
determining how big it is with evsel__id_hdr_size() and then subtracting
that from the event size.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kvm@vger.kernel.org
Link: https://lore.kernel.org/r/20220711093218.10967-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h