Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3112381rwb; Mon, 7 Aug 2023 08:25:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGV/W/q1rw35rIM0Qi/DLQC8AThp8DcMdWHzMaj37VB5PCAfYqlbnxK2O/et5tque1h6GFg X-Received: by 2002:a05:6a21:7887:b0:13e:b6b0:72a2 with SMTP id bf7-20020a056a21788700b0013eb6b072a2mr8646338pzc.6.1691421889449; Mon, 07 Aug 2023 08:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691421889; cv=none; d=google.com; s=arc-20160816; b=cDN95vT0cLYuXY7MLdJr+jis09PeyH2B6ofdGMC0qAa5NxYPD8MvvoxYYWt4B5UPiw 8MMMoHCRytCbJB+Q2FXCDSvSsZbe1ABj/YOJCfWmyvVmebaOMagpFCKFGF7vwG+XjraI 3aoEAbJGn0ZShP8KPr3u4y8wFbtcTru2M1Qmmj2Qw7SPAHY03Iqy3aVr24wl7ZZz8PGl HVFLWplQpjlfA+sc1O2v1zcbOzV4ZUkiYe3NEfldmsBeUyCTDFpIbuftdQIvzajslsw4 +5K/134QODk0F8CqYrp0ugMsb9GQWntGRsb5M6OOTEctS31/huYTpAfYJlrQuZo7JjF7 DgMg== 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=TP+9bRqC8qR7elXDpzrp1ZKI8X95ImnaOT+dOwXx/m4=; fh=8SSoTIDDf0TzQUEQSH0PxE5ICJlaQRTGc6pNUwjsBIE=; b=tv+D3ryBwwtPvBZUYMA5ZdsEz1ak0NsWky1Dl/lDKjLnEnCvRQSE9gid0PT7rhJlHW BtQUTZ8bvBR3DaSJWoGTWBCjQhPYldAiC9tiImFBbPEgsMkZCju1vSisJdr15BGQDMg8 9aM7diPgnhfyCuU23ZV/A28MNUXvaHdo2zUDL+CMr4WQQDlOuSOEBue1TI7PKwNr6Xqq xiOF02PRi7B8+cpCt0JmgdZbLCS3ZTvhl+mCwP2hjid7PDRba/sfQz20jbyDwVVRKYGA U8GGogrXQrW2eXZyyGXzM7pBfK4maXTaoTz3lTBBWN7uWTXpkJY4z4RMzGBPtTu4ef9J bKbw== 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 f12-20020a056a001acc00b00686da99493bsi5922535pfv.221.2023.08.07.08.24.37; Mon, 07 Aug 2023 08:24:49 -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 S231382AbjHGOYg (ORCPT + 99 others); Mon, 7 Aug 2023 10:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjHGOYe (ORCPT ); Mon, 7 Aug 2023 10:24:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F8A7107; Mon, 7 Aug 2023 07:24:33 -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 004BD1FB; Mon, 7 Aug 2023 07:25:16 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 107C73F64C; Mon, 7 Aug 2023 07:24:29 -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 Cc: James Clark , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , Kan Liang , Nick Forrington , Eduard Zingerman , Rob Herring , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Subject: [PATCH v4 3/6] perf test: Add a test for the new Arm CPU ID comparison behavior Date: Mon, 7 Aug 2023 15:20:47 +0100 Message-Id: <20230807142138.288713-4-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807142138.288713-1-james.clark@arm.com> References: <20230807142138.288713-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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. 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