Skip to content

Commit 9eef3ec

Browse files
Leo-Yanacmel
authored andcommitted
perf cpumap: Add checking for reference counter
For the CPU map merging test, add an extra check for the reference counter before releasing the last CPU map. Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Leo Yan <leo.yan@arm.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20241107125308.41226-4-leo.yan@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent fb953df commit 9eef3ec

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/perf/tests/cpumap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ static int __test__cpu_map_merge(const char *lhs, const char *rhs, int nr, const
167167
cpu_map__snprint(a, buf, sizeof(buf));
168168
TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, expected));
169169
perf_cpu_map__put(b);
170+
171+
/*
172+
* If 'b' is a superset of 'a', 'a' points to the same map with the
173+
* map 'b'. In this case, the owner 'b' has released the resource above
174+
* but 'a' still keeps the ownership, the reference counter should be 1.
175+
*/
176+
TEST_ASSERT_VAL("unexpected refcnt: bad result",
177+
refcount_read(perf_cpu_map__refcnt(a)) == 1);
178+
170179
perf_cpu_map__put(a);
171180
return 0;
172181
}

0 commit comments

Comments
 (0)