linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Leo Yan <leo.yan@arm.com>, Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>,
	tmricht@linux.ibm.com, acme@kernel.org, jolsa@kernel.org,
	adrian.hunter@intel.com, linux-perf-users@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, akanksha@linux.ibm.com,
	maddy@linux.ibm.com, kjain@linux.ibm.com,
	disgoel@linux.vnet.ibm.com, hbathini@linux.ibm.com,
	Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH] tools/perf/tests/expr: Make the system_tsc_freq test only for intel
Date: Tue, 3 Dec 2024 10:42:45 -0800	[thread overview]
Message-ID: <Z09RJbpmHzc4b1D6@google.com> (raw)
In-Reply-To: <Z09K5orKhWbeOGLV@google.com>

On Tue, Dec 03, 2024 at 10:16:06AM -0800, Namhyung Kim wrote:
> Hello,
> 
> On Fri, Nov 08, 2024 at 10:50:10AM +0530, Athira Rajeev wrote:
> > 
> > 
> > > On 7 Nov 2024, at 7:26 PM, Leo Yan <leo.yan@arm.com> wrote:
> > > 
> > > Hi Athira,
> > > 
> > > On Wed, Nov 06, 2024 at 03:04:57PM +0530, Athira Rajeev wrote:
> > > 
> > > [...]
> > > 
> > >>> Hi Athira,
> > >>> 
> > >>> sorry for the breakage and thank you for the detailed explanation. As
> > >>> the code will run on AMD I think your change will break that - . It is
> > >>> probably safest to keep the ".. else { .." for this case but guard it
> > >>> in the ifdef.
> > >>> 
> > >> 
> > >> Hi Ian
> > >> 
> > >> Thanks for your comments. Does the below change looks good ?
> > >> 
> > >> diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
> > >> index e3aa9d4fcf3a..f5b2d96bb59b 100644
> > >> --- a/tools/perf/tests/expr.c
> > >> +++ b/tools/perf/tests/expr.c
> > >> @@ -74,14 +74,12 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
> > >>    double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages;
> > >>    int ret;
> > >>    struct expr_parse_ctx *ctx;
> > >> -    bool is_intel = false;
> > >>    char strcmp_cpuid_buf[256];
> > >>    struct perf_pmu *pmu = perf_pmus__find_core_pmu();
> > >>    char *cpuid = perf_pmu__getcpuid(pmu);
> > >>    char *escaped_cpuid1, *escaped_cpuid2;
> > >> 
> > >>    TEST_ASSERT_VAL("get_cpuid", cpuid);
> > >> -    is_intel = strstr(cpuid, "Intel") != NULL;
> > >> 
> > >>    TEST_ASSERT_EQUAL("ids_union", test_ids_union(), 0);
> > >> 
> > >> @@ -244,11 +242,13 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
> > >>    if (num_dies) // Some platforms do not have CPU die support, for example s390
> > >>        TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages);
> > >> 
> > >> +#if defined(__i386__) && defined(__x86_64__)
> > >>    TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0);
> > >> -    if (is_intel)
> > >> +    if (strstr(cpuid, "Intel") != NULL)
> > >>        TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
> > >>    else
> > >>        TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);
> > >> +#endif
> > >> 
> > >>    /*
> > >>     * Source count returns the number of events aggregating in a leader
> > > 
> > > I confirmed the change above fixes the failure on Arm64.
> > > 
> > > Tested-by: Leo Yan <leo.yan@arm.com>
> > Thanks Leo Yan for testing.
> > 
> > Hi Ian,
> > 
> > If the change above looks good, I will post a V2 . Please share your review comments
> 
> Sorry for the delay, it looks good to me.  Can you please send the v2?

After looking at another report, I think we need to check the value of
TSC freq, not just the vendor.  Can you please test this?

Thanks,
Namhyung


---8<---
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index 41ff1affdfcdf31c..45151696e7b76308 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -5,6 +5,7 @@
 #include "util/hashmap.h"
 #include "util/header.h"
 #include "util/smt.h"
+#include "util/tsc.h"
 #include "tests.h"
 #include <perf/cpumap.h>
 #include <math.h>
@@ -75,14 +76,12 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
 	double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages;
 	int ret;
 	struct expr_parse_ctx *ctx;
-	bool is_intel = false;
 	char strcmp_cpuid_buf[256];
 	struct perf_cpu cpu = {-1};
 	char *cpuid = get_cpuid_allow_env_override(cpu);
 	char *escaped_cpuid1, *escaped_cpuid2;
 
 	TEST_ASSERT_VAL("get_cpuid", cpuid);
-	is_intel = strstr(cpuid, "Intel") != NULL;
 
 	TEST_ASSERT_EQUAL("ids_union", test_ids_union(), 0);
 
@@ -246,10 +245,10 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
 		TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages);
 
 	TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0);
-	if (is_intel)
-		TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0);
-	else
-		TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO);
+	if (val > 0) {
+		TEST_ASSERT_VAL("#system_tsc_freq == arch_get_tsc_freq()",
+				val == arch_get_tsc_freq());
+	}
 
 	/*
 	 * Source count returns the number of events aggregating in a leader

  reply	other threads:[~2024-12-03 18:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22 14:01 [PATCH] tools/perf/tests/expr: Make the system_tsc_freq test only for intel Athira Rajeev
2024-10-29 23:59 ` Namhyung Kim
2024-11-04  4:17   ` Athira Rajeev
2024-11-04 20:44     ` Ian Rogers
2024-11-06  9:34       ` Athira Rajeev
2024-11-07 13:56         ` Leo Yan
2024-11-08  5:20           ` Athira Rajeev
2024-12-03 18:16             ` Namhyung Kim
2024-12-03 18:42               ` Namhyung Kim [this message]
2024-12-03 18:59                 ` Namhyung Kim
2024-12-05 17:00               ` Athira Rajeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z09RJbpmHzc4b1D6@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=akanksha@linux.ibm.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=hbathini@linux.ibm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=leo.yan@arm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=sashal@kernel.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).