|
23 | 23 | #include "pmu.h"
|
24 | 24 | #include "pmu-hybrid.h"
|
25 | 25 |
|
| 26 | +/* |
| 27 | + * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just |
| 28 | + * enable the test for x86_64/i386 and Arm64 archs. |
| 29 | + */ |
| 30 | +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) |
| 31 | +#define TSC_IS_SUPPORTED 1 |
| 32 | +#else |
| 33 | +#define TSC_IS_SUPPORTED 0 |
| 34 | +#endif |
| 35 | + |
26 | 36 | #define CHECK__(x) { \
|
27 | 37 | while ((x) < 0) { \
|
28 | 38 | pr_debug(#x " failed!\n"); \
|
@@ -69,6 +79,11 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
|
69 | 79 | u64 test_time, comm1_time = 0, comm2_time = 0;
|
70 | 80 | struct mmap *md;
|
71 | 81 |
|
| 82 | + if (!TSC_IS_SUPPORTED) { |
| 83 | + pr_debug("Test not supported on this architecture"); |
| 84 | + return TEST_SKIP; |
| 85 | + } |
| 86 | + |
72 | 87 | threads = thread_map__new(-1, getpid(), UINT_MAX);
|
73 | 88 | CHECK_NOT_NULL__(threads);
|
74 | 89 |
|
@@ -185,26 +200,4 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
|
185 | 200 | return err;
|
186 | 201 | }
|
187 | 202 |
|
188 |
| -static bool test__tsc_is_supported(void) |
189 |
| -{ |
190 |
| - /* |
191 |
| - * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. |
192 |
| - * Just enable the test for x86_64/i386 and Arm64 archs. |
193 |
| - */ |
194 |
| -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) |
195 |
| - return true; |
196 |
| -#else |
197 |
| - return false; |
198 |
| -#endif |
199 |
| -} |
200 |
| - |
201 |
| -static struct test_case perf_time_to_tsc_tests[] = { |
202 |
| - TEST_CASE("Convert perf time to TSC", perf_time_to_tsc), |
203 |
| - { .name = NULL, } |
204 |
| -}; |
205 |
| - |
206 |
| -struct test_suite suite__perf_time_to_tsc = { |
207 |
| - .desc = "Convert perf time to TSC", |
208 |
| - .test_cases = perf_time_to_tsc_tests, |
209 |
| - .is_supported = test__tsc_is_supported, |
210 |
| -}; |
| 203 | +DEFINE_SUITE("Convert perf time to TSC", perf_time_to_tsc); |
0 commit comments