summaryrefslogtreecommitdiff
path: root/tools/perf/util/synthetic-events.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2022-06-10 14:33:13 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-06-23 17:54:22 +0300
commit6b080312fc821658a479e74bdb0c3f7d9ac5838f (patch)
treeb352ced9650c1bc008eae0ba0e8e0a923a7b45ad /tools/perf/util/synthetic-events.c
parentf42c0ce573df79d1b8bd169008c994dcdd43585a (diff)
downloadlinux-6b080312fc821658a479e74bdb0c3f7d9ac5838f.tar.xz
perf record: Always record id index
In preparation for recording sideband events in a virtual machine guest so that they can be injected into a host perf.data file. Adjust the logic so that if there are IDs then the id index is recorded. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20220610113316.6682-3-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/synthetic-events.c')
-rw-r--r--tools/perf/util/synthetic-events.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 27acdc5e5723..d75074486a55 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -1719,14 +1719,17 @@ int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_
size_t nr = 0, i = 0, sz, max_nr, n;
int err;
- pr_debug2("Synthesizing id index\n");
-
max_nr = (UINT16_MAX - sizeof(struct perf_record_id_index)) /
sizeof(struct id_index_entry);
evlist__for_each_entry(evlist, evsel)
nr += evsel->core.ids;
+ if (!nr)
+ return 0;
+
+ pr_debug2("Synthesizing id index\n");
+
n = nr > max_nr ? max_nr : nr;
sz = sizeof(struct perf_record_id_index) + n * sizeof(struct id_index_entry);
ev = zalloc(sz);