Skip to content

Commit

Permalink
perf test: Add a test for the new Arm CPU ID comparison behavior
Browse files Browse the repository at this point in the history
Now that variant and revision fields are taken into account the behavior
is slightly more complicated so add a test to ensure that this behaves
as expected.

Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: James Clark <james.clark@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Forrington <nick.forrington@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Sohom Datta <sohomdatta1@gmail.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230816114841.1679234-3-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
James Clark authored and Arnaldo Carvalho de Melo committed Aug 17, 2023
1 parent c3e1e8c commit 81f7da5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/perf/arch/arm64/include/arch-tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

struct test_suite;

int test__cpuid_match(struct test_suite *test, int subtest);
extern struct test_suite *arch_tests[];

#endif
1 change: 1 addition & 0 deletions tools/perf/arch/arm64/tests/Build
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ perf-y += regs_load.o
perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o

perf-y += arch-tests.o
perf-y += cpuid-match.o
4 changes: 4 additions & 0 deletions tools/perf/arch/arm64/tests/arch-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
#include "tests/tests.h"
#include "arch-tests.h"


DEFINE_SUITE("arm64 CPUID matching", cpuid_match);

struct test_suite *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
&suite__dwarf_unwind,
#endif
&suite__cpuid_match,
NULL,
};
37 changes: 37 additions & 0 deletions tools/perf/arch/arm64/tests/cpuid-match.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>

#include "arch-tests.h"
#include "tests/tests.h"
#include "util/header.h"

int test__cpuid_match(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
/* midr with no leading zeros matches */
if (strcmp_cpuid_str("0x410fd0c0", "0x00000000410fd0c0"))
return -1;
/* Upper case matches */
if (strcmp_cpuid_str("0x410fd0c0", "0x00000000410FD0C0"))
return -1;
/* r0p0 = r0p0 matches */
if (strcmp_cpuid_str("0x00000000410fd480", "0x00000000410fd480"))
return -1;
/* r0p1 > r0p0 matches */
if (strcmp_cpuid_str("0x00000000410fd480", "0x00000000410fd481"))
return -1;
/* r1p0 > r0p0 matches*/
if (strcmp_cpuid_str("0x00000000410fd480", "0x00000000411fd480"))
return -1;
/* r0p0 < r0p1 doesn't match */
if (!strcmp_cpuid_str("0x00000000410fd481", "0x00000000410fd480"))
return -1;
/* r0p0 < r1p0 doesn't match */
if (!strcmp_cpuid_str("0x00000000411fd480", "0x00000000410fd480"))
return -1;
/* Different CPU doesn't match */
if (!strcmp_cpuid_str("0x00000000410fd4c0", "0x00000000430f0af0"))
return -1;

return 0;
}

0 comments on commit 81f7da5

Please sign in to comment.