Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1368608rdb; Wed, 16 Aug 2023 09:24:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IES10gXGulVhiuluYvZ5yvjbZWYyPSaEtTFL6A4Li6edTZgwdKVQ9B25yUy7c3hCiqoTfBA X-Received: by 2002:a05:6a00:2344:b0:688:49e6:d113 with SMTP id j4-20020a056a00234400b0068849e6d113mr2985391pfj.34.1692203068869; Wed, 16 Aug 2023 09:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692203068; cv=none; d=google.com; s=arc-20160816; b=pOz5PQHaRS3tWEU6uVnk6TwqzUuCUWahVUtLmgAVxhlttE60jnowo+RXz7qU+1qfC9 v+6m5Pz+CqRJfjSTE/WmOmYtToqY06xH6qdYQz97Rh+Q7A1I6nhTVXPaQoUy2A89+Qry uu2nvttM0XVduZlDcAE/kpucPYrjZfe0PAYmm62Wj0I18A0/NT96+qiuGgBYitQst03/ tATJBdszvzi1QOH53MHVs9N3fyELvcWGrsCauuJUoAfADvBg4us6CP1yFcERtLxMl04l a7Wxcd5dSq6C4cXKTi0NzJKduM5IOx/0WdRoPKljw/R5BM7WKzC2qVvqH1Kb29tLUpYJ htHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=1THI8i50kufL6kHwy6UKTMwX5oFg4LfFUrSNoct+32E=; fh=bHT3wjGnhA8+b5+mPAMt5cxUNNBzdn4RVorq2qnBPG4=; b=mBOk/UzUz68BXqCDUyFahbMt/0v629Dtlw1NlAT1r/X444qD4QfvTyuheGhivlW7KT a0fhPkrlL3Ta2IdRQMki++v0QaDmwMlHeqfNVy6WIU9sn2Tm+EyPGlPx5KXCCd0bFkfv EDNLOL3j+hmfWHF0P7Y2CtrhrIrfJt7RqG+qcz6pNNPnyggm3Ydv5fJmFIUpEWiivngV OVcDUgOcXXG+7a6TR5ZsQDh16j/fFiDM2LO9gn/sDwhFHbVp5MbkowlyawToIRyfvsFG lbUdjGCwysJG+z6ELsBhyc4vbCXr74hT4tQF6H+TulaAfdnkVV1X57is4elBL3ONeKA8 pC7Q== 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 m1-20020a656a01000000b00565e542a416si2698223pgu.414.2023.08.16.09.24.15; Wed, 16 Aug 2023 09:24:28 -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 S243239AbjHPJO7 (ORCPT + 99 others); Wed, 16 Aug 2023 05:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243231AbjHPJOj (ORCPT ); Wed, 16 Aug 2023 05:14:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FCA7173F; Wed, 16 Aug 2023 02:14:38 -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 E4CC01063; Wed, 16 Aug 2023 02:15:18 -0700 (PDT) Received: from [10.57.2.104] (unknown [10.57.2.104]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 952E63F64C; Wed, 16 Aug 2023 02:14:34 -0700 (PDT) Message-ID: Date: Wed, 16 Aug 2023 10:14:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v5 3/6] perf test: Add a test for the new Arm CPU ID comparison behavior Content-Language: en-US To: John Garry , linux-perf-users@vger.kernel.org, irogers@google.com, renyu.zj@linux.alibaba.com Cc: 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 , Kajol Jain , Nick Forrington , Kan Liang , Eduard Zingerman , Sohom Datta , Rob Herring , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org References: <20230811144017.491628-1-james.clark@arm.com> <20230811144017.491628-4-james.clark@arm.com> <3c382d80-7666-8207-a534-0b20807d3f6c@oracle.com> From: James Clark In-Reply-To: <3c382d80-7666-8207-a534-0b20807d3f6c@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 On 15/08/2023 10:47, John Garry wrote: > On 11/08/2023 15:39, James Clark wrote: >> 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; >> +} >> + > > Would it be possible to put this in core test code, since x86 also > supports strcmp_cpuid_str()? > That's how I started, but Ian suggested to move it to an arch specific folder because that's what it was testing. We could still add test__cpuid_match() in the x86 folder rather than adding it with #ifdefs, but I don't think it needs to be done here because I haven't touched the x86 code. > Maybe we would have an structure per arch of cpuids and expected > results, like > > struct cpuid_match { >     char *cpuid1; >     char *cpuid1; >     int expected_result; > }; > > > #ifdef ARM64 >  cpuid_match_array[] = { >     {"0x410fd0c0", "0x00000000410FD0C0", -1}, >     {"0x00000000410fd480", "0x00000000410fd480", -1}, >     ... >     {} /* sentinel */ > > }; > #else if defined(X86) >  cpuid_match_array[] = { >     {....} >     ... >     {} /* sentinel */ > > }; > #else > /* no support */ > #endif > > Thanks, > John