[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220307085312.1814506-7-adrian.hunter@intel.com>
Date: Mon, 7 Mar 2022 10:53:08 +0200
From: Adrian Hunter <adrian.hunter@...el.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
kvm@...r.kernel.org, H Peter Anvin <hpa@...or.com>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Leo Yan <leo.yan@...aro.org>
Subject: [PATCH V3 06/10] perf tools: Add new clock IDs to "perf time to TSC" test
The same "Convert perf time to TSC" test can be used with new clock IDs
CLOCK_PERF_HW_CLOCK and CLOCK_PERF_HW_CLOCK_NS.
Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
tools/perf/tests/perf-time-to-tsc.c | 42 ++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index d12d0ad81801..62840ec98cea 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -22,6 +22,8 @@
#include "tests.h"
#include "pmu.h"
#include "pmu-hybrid.h"
+#include "clockid.h"
+#include "perf_api_probe.h"
/*
* Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just
@@ -47,15 +49,7 @@
} \
}
-/**
- * test__perf_time_to_tsc - test converting perf time to TSC.
- *
- * This function implements a test that checks that the conversion of perf time
- * to and from TSC is consistent with the order of events. If the test passes
- * %0 is returned, otherwise %-1 is returned. If TSC conversion is not
- * supported then then the test passes but " (not supported)" is printed.
- */
-static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
+static int perf_time_to_tsc_test(bool use_clockid, s32 clockid)
{
struct record_opts opts = {
.mmap_pages = UINT_MAX,
@@ -104,6 +98,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
evsel->core.attr.comm = 1;
evsel->core.attr.disabled = 1;
evsel->core.attr.enable_on_exec = 0;
+ evsel->core.attr.use_clockid = use_clockid;
+ evsel->core.attr.clockid = clockid;
/*
* For hybrid "cycles:u", it creates two events.
@@ -200,4 +196,32 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
return err;
}
+/**
+ * test__perf_time_to_tsc - test converting perf time to TSC.
+ *
+ * This function implements a test that checks that the conversion of perf time
+ * to and from TSC is consistent with the order of events. If the test passes
+ * %0 is returned, otherwise %-1 is returned. If TSC conversion is not
+ * supported then the test passes but " (not supported)" is printed.
+ */
+static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
+{
+ int err;
+
+ err = perf_time_to_tsc_test(false, 0);
+
+ if (!err && perf_can_perf_clock_hw_clock()) {
+ pr_debug("Testing CLOCK_PERF_HW_CLOCK\n");
+ err = perf_time_to_tsc_test(true, CLOCK_PERF_HW_CLOCK);
+ }
+
+ if (!err && perf_can_perf_clock_hw_clock_ns()) {
+ pr_debug("Testing CLOCK_PERF_HW_CLOCK_NS\n");
+ err = perf_time_to_tsc_test(true, CLOCK_PERF_HW_CLOCK_NS);
+ }
+
+ return err;
+}
+
DEFINE_SUITE("Convert perf time to TSC", perf_time_to_tsc);
--
2.25.1
Powered by blists - more mailing lists