Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test expr: Fix system_tsc_freq for only x86

The refactoring of tool PMU events to have a PMU then adding the expr
literals to the tool PMU made it so that the literal system_tsc_freq
was only supported on x86. Update the test expectations to match -
namely the parsing is x86 specific and only yields a non-zero value on
Intel.

Fixes: 609aa2667f67 ("perf tool_pmu: Switch to standard pmu functions and json descriptions")
Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Closes: https://lore.kernel.org/linux-perf-users/20241022140156.98854-1-atrajeev@linux.vnet.ibm.com/
Co-developed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: akanksha@linux.ibm.com
Cc: hbathini@linux.ibm.com
Cc: kjain@linux.ibm.com
Cc: maddy@linux.ibm.com
Cc: disgoel@linux.vnet.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20241205022305.158202-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
a93a620c d4e17a32

+12 -7
+12 -7
tools/perf/tests/expr.c
··· 75 75 double val, num_cpus_online, num_cpus, num_cores, num_dies, num_packages; 76 76 int ret; 77 77 struct expr_parse_ctx *ctx; 78 - bool is_intel = false; 79 78 char strcmp_cpuid_buf[256]; 80 79 struct perf_cpu cpu = {-1}; 81 80 char *cpuid = get_cpuid_allow_env_override(cpu); 82 81 char *escaped_cpuid1, *escaped_cpuid2; 83 82 84 83 TEST_ASSERT_VAL("get_cpuid", cpuid); 85 - is_intel = strstr(cpuid, "Intel") != NULL; 86 84 87 85 TEST_ASSERT_EQUAL("ids_union", test_ids_union(), 0); 88 86 ··· 243 245 if (num_dies) // Some platforms do not have CPU die support, for example s390 244 246 TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages); 245 247 246 - TEST_ASSERT_VAL("#system_tsc_freq", expr__parse(&val, ctx, "#system_tsc_freq") == 0); 247 - if (is_intel) 248 - TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0); 249 - else 250 - TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO); 251 248 249 + if (expr__parse(&val, ctx, "#system_tsc_freq") == 0) { 250 + bool is_intel = strstr(cpuid, "Intel") != NULL; 251 + 252 + if (is_intel) 253 + TEST_ASSERT_VAL("#system_tsc_freq > 0", val > 0); 254 + else 255 + TEST_ASSERT_VAL("#system_tsc_freq == 0", fpclassify(val) == FP_ZERO); 256 + } else { 257 + #if defined(__i386__) || defined(__x86_64__) 258 + TEST_ASSERT_VAL("#system_tsc_freq unsupported", 0); 259 + #endif 260 + } 252 261 /* 253 262 * Source count returns the number of events aggregating in a leader 254 263 * event including the leader. Check parsing yields an id.