mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-25 00:52:45 -04:00
libperf: Fix perf_cpu_map__for_each_cpu macro
Tzvetomir Stoyanov reported an issue with using macro
perf_cpu_map__for_each_cpu using private perf_cpu object.
The issue is caused by recent change that wrapped cpu in struct perf_cpu
to distinguish it from cpu indexes. We need to make struct perf_cpu
public.
Add a simple test for using the perf_cpu_map__for_each_cpu macro.
Fixes: 6d18804b96 ("perf cpumap: Give CPUs their own type")
Reported-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20220215153713.31395-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
9de0736973
commit
30d1c4d947
@@ -14,6 +14,8 @@ static int libperf_print(enum libperf_print_level level,
|
||||
int test_cpumap(int argc, char **argv)
|
||||
{
|
||||
struct perf_cpu_map *cpus;
|
||||
struct perf_cpu cpu;
|
||||
int idx;
|
||||
|
||||
__T_START;
|
||||
|
||||
@@ -27,6 +29,15 @@ int test_cpumap(int argc, char **argv)
|
||||
perf_cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
|
||||
cpus = perf_cpu_map__default_new();
|
||||
if (!cpus)
|
||||
return -1;
|
||||
|
||||
perf_cpu_map__for_each_cpu(cpu, idx, cpus)
|
||||
__T("wrong cpu number", cpu.cpu != -1);
|
||||
|
||||
perf_cpu_map__put(cpus);
|
||||
|
||||
__T_END;
|
||||
return tests_failed == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user