]> git.ipfire.org Git - people/ms/linux.git/commitdiff
perf record: Fix cpu mask bit setting for mixed mmaps
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 15 Sep 2022 12:26:11 +0000 (15:26 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 21 Sep 2022 19:08:00 +0000 (16:08 -0300)
With mixed per-thread and (system-wide) per-cpu maps, the "any cpu" value
 -1 must be skipped when setting CPU mask bits.

Prior to commit cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access
to cpu mask array") the invalid setting went unnoticed, but since then
it causes perf record to fail with an error.

Example:

 Before:

   $ perf record -e intel_pt// --per-thread uname
   Failed to initialize parallel data streaming masks

 After:

   $ perf record -e intel_pt// --per-thread uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.068 MB perf.data ]

Fixes: ae4f8ae16a078964 ("libperf evlist: Allow mixing per-thread and per-cpu mmaps")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220915122612.81738-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c

index f87ef43eb8204a173901975d55da4e87426598a9..0f711f88894cf9ebf87cfa00c390b2e781b8e8b2 100644 (file)
@@ -3371,6 +3371,8 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cp
                return 0;
 
        perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
+               if (cpu.cpu == -1)
+                       continue;
                /* Return ENODEV is input cpu is greater than max cpu */
                if ((unsigned long)cpu.cpu > mask->nbits)
                        return -ENODEV;