Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1930322rdb; Thu, 17 Aug 2023 06:21:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXgRfcO8rV9KyJnUvJ78OmtExYlLwk0wViUZ6r0dcKSKeVHiSl0dTiq7Hqxn3tzLqUDtua X-Received: by 2002:a17:902:d355:b0:1bf:148b:58ff with SMTP id l21-20020a170902d35500b001bf148b58ffmr1369481plk.69.1692278517682; Thu, 17 Aug 2023 06:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692278517; cv=none; d=google.com; s=arc-20160816; b=mjDvOJ7A7V8T3kDQI6VgexJ76NKlLfV4PagZWY5cpZr63iIGnIocuP9d25jSkozX0y QT9z8Lat0Cj1xptLyJwtRumy1m4YfygOfCmDg+9AFTgqqCqoiejIgMDEsz4YR4/3/mfu SpkTZhNyLis4TtlqWn8peRBjICYrZmFiiTE8Cf+isllTMSBj979Nn6a2tAAGODrw0tnI pQIjqENaz+jX4Ko6IpFYcBX9szCJxOLRmt8AvHARAuR4cMeJefxdHSskfwjbhMytUVRM HNBNf1ISWZQ7EzIPQFjebQ1w1WPBwVZxPkzGfpc+Kx83U5gnrXn7Ak9M661+qj5yQhNH N8cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=w+4KmJPfW3sMrsp4D92CpJjI+UHzmmNYHu7Ng/ZeluI=; fh=ZC4ca3dh4PVUiV3vxYj6ctqMgStLuX3Q2Ysb2Txg7Ws=; b=CKTHFUNanRdRtiMMkVLxU4+YSL0RJ9O9E11v+OfdSPYesOEkAHYQuMI19NN8QjRMmr iZNPwe2GAQkZH5KGWjf99pgUNnwGMqxutJrU81+2uQSbVC7Kzi26gi8yvZBpLmctlIRe v8t0gw5FD1EnfVj/hE+oEKUKMEk1rGcEHLZstU4WbbYbIypvnrZIca+EEAp341VJo4iL By2ySlGUAqnAj2mIBvX0+q+T+2RsbgcXUFa3QPUpA5s1PdJeQT6tdwGAIjwXezASSr9I kGS3IATPb5Xh/wqy2h8tppNi0IaXYhZMcHihFxkQPhLz3l+C77veMo1f+24/aqvNbxkT VmzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik11-20020a170902ab0b00b001bf1973eaffsi859735plb.559.2023.08.17.06.21.43; Thu, 17 Aug 2023 06:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244399AbjHPLvk (ORCPT + 99 others); Wed, 16 Aug 2023 07:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244802AbjHPLvI (ORCPT ); Wed, 16 Aug 2023 07:51:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 378C32121; Wed, 16 Aug 2023 04:50:57 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E6411063; Wed, 16 Aug 2023 04:51:38 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.4.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7E76C3F64C; Wed, 16 Aug 2023 04:50:53 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com, john.g.garry@oracle.com, renyu.zj@linux.alibaba.com, acme@kernel.org Cc: James Clark , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Haixin Yu , Nick Forrington , Kajol Jain , Eduard Zingerman , Sohom Datta , Rob Herring , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 2/6] perf test: Add a test for the new Arm CPU ID comparison behavior Date: Wed, 16 Aug 2023 12:47:44 +0100 Message-Id: <20230816114841.1679234-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816114841.1679234-1-james.clark@arm.com> References: <20230816114841.1679234-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: James Clark --- tools/perf/arch/arm64/include/arch-tests.h | 3 ++ tools/perf/arch/arm64/tests/Build | 1 + tools/perf/arch/arm64/tests/arch-tests.c | 4 +++ tools/perf/arch/arm64/tests/cpuid-match.c | 38 ++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 tools/perf/arch/arm64/tests/cpuid-match.c diff --git a/tools/perf/arch/arm64/include/arch-tests.h b/tools/perf/arch/arm64/include/arch-tests.h index 452b3d904521..474d7cf5afbd 100644 --- a/tools/perf/arch/arm64/include/arch-tests.h +++ b/tools/perf/arch/arm64/include/arch-tests.h @@ -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 diff --git a/tools/perf/arch/arm64/tests/Build b/tools/perf/arch/arm64/tests/Build index a61c06bdb757..e337c09e7f56 100644 --- a/tools/perf/arch/arm64/tests/Build +++ b/tools/perf/arch/arm64/tests/Build @@ -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 diff --git a/tools/perf/arch/arm64/tests/arch-tests.c b/tools/perf/arch/arm64/tests/arch-tests.c index ad16b4f8f63e..74932e72c727 100644 --- a/tools/perf/arch/arm64/tests/arch-tests.c +++ b/tools/perf/arch/arm64/tests/arch-tests.c @@ -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, }; diff --git a/tools/perf/arch/arm64/tests/cpuid-match.c b/tools/perf/arch/arm64/tests/cpuid-match.c new file mode 100644 index 000000000000..af0871b54ae7 --- /dev/null +++ b/tools/perf/arch/arm64/tests/cpuid-match.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +#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; +} + -- 2.34.1