From: Adrian Hunter <adrian.hunter@intel.com>
To: Chen Pei <cp0613@linux.alibaba.com>, <acme@kernel.org>,
<peterz@infradead.org>, <mingo@redhat.com>, <namhyung@kernel.org>
Cc: <mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
<jolsa@kernel.org>, <irogers@google.com>,
<james.clark@linaro.org>, <leo.yan@linux.dev>,
<john.g.garry@oracle.com>, <will@kernel.org>,
<mike.leach@arm.com>, <pjw@kernel.org>, <palmer@dabbelt.com>,
<guoren@kernel.org>, <linux-perf-users@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] perf tsc: Declare TSC support from the build system
Date: Tue, 6 Oct 2026 16:16:52 +0300 [thread overview]
Message-ID: <66136aa8-adbe-4fdf-9b7c-d44ea0e5cf1e@intel.com> (raw)
In-Reply-To: <20260929034133.2153-3-cp0613@linux.alibaba.com>
On 29/09/2026 06:41, Chen Pei wrote:
> The "TSC support" subtest of the "Convert perf time to TSC" test decides
> whether the architecture is covered by matching compiler macros for
> x86_64, i386 and arm64. That list has to be edited for every new
> architecture and can drift apart from the set of architectures that really
> provide a counter.
>
> Declare the capability where the implementation is, following the
> PERF_HAVE_JITDUMP pattern: an architecture with a usable counter sets
> PERF_HAVE_RDTSC in its arch Makefile, Makefile.config turns it into
> -DHAVE_RDTSC, and the test keys off that.
>
> x86 and arm64 keep the same behaviour, riscv starts running the subtest
> where the previous patch defines rdtsc().
>
> Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
One minor style comment below. In any case:
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> Changes in v2:
> - Declare the capability through the build system instead of a weak
> arch__rdtsc_supported() hook.
>
> tools/perf/Makefile.config | 4 ++++
> tools/perf/arch/arm64/Makefile | 1 +
> tools/perf/arch/riscv/Makefile | 1 +
> tools/perf/arch/x86/Makefile | 1 +
> tools/perf/tests/perf-time-to-tsc.c | 19 ++++---------------
> 5 files changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 4d5993da9f94..f1b3bf208231 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -618,6 +618,10 @@ ifdef PERF_HAVE_JITDUMP
> endif
> endif
>
> +ifeq ($(PERF_HAVE_RDTSC),1)
> + CFLAGS += -DHAVE_RDTSC
> +endif
> +
> ifeq ($(SRCARCH),powerpc)
> ifndef NO_LIBDW
> CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
> diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
> index 44cc3f023318..b9cd559065d6 100644
> --- a/tools/perf/arch/arm64/Makefile
> +++ b/tools/perf/arch/arm64/Makefile
> @@ -1,2 +1,3 @@
> # SPDX-License-Identifier: GPL-2.0
> PERF_HAVE_JITDUMP := 1
> +PERF_HAVE_RDTSC := 1
> diff --git a/tools/perf/arch/riscv/Makefile b/tools/perf/arch/riscv/Makefile
> index 44cc3f023318..8036bf55da8e 100644
> --- a/tools/perf/arch/riscv/Makefile
> +++ b/tools/perf/arch/riscv/Makefile
> @@ -1,2 +1,3 @@
> # SPDX-License-Identifier: GPL-2.0
> PERF_HAVE_JITDUMP := 1
> +PERF_HAVE_RDTSC := $(IS_64_BIT)
> diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
> index 44cc3f023318..b9cd559065d6 100644
> --- a/tools/perf/arch/x86/Makefile
> +++ b/tools/perf/arch/x86/Makefile
> @@ -1,2 +1,3 @@
> # SPDX-License-Identifier: GPL-2.0
> PERF_HAVE_JITDUMP := 1
> +PERF_HAVE_RDTSC := 1
> diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
> index f8f71fdd32b1..feb8063f8b59 100644
> --- a/tools/perf/tests/perf-time-to-tsc.c
> +++ b/tools/perf/tests/perf-time-to-tsc.c
> @@ -22,16 +22,6 @@
> #include "tests.h"
> #include "util/sample.h"
>
> -/*
> - * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just
> - * enable the test for x86_64/i386 and Arm64 archs.
> - */
> -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
> -#define TSC_IS_SUPPORTED 1
> -#else
> -#define TSC_IS_SUPPORTED 0
> -#endif
> -
> #define CHECK__(x) { \
> while ((x) < 0) { \
> pr_debug(#x " failed!\n"); \
> @@ -49,11 +39,10 @@
> static int test__tsc_is_supported(struct test_suite *test __maybe_unused,
> int subtest __maybe_unused)
> {
> - if (!TSC_IS_SUPPORTED) {
> - pr_debug("Test not supported on this architecture\n");
> - return TEST_SKIP;
> - }
> -
> +#ifndef HAVE_RDTSC
> + pr_debug("Test not supported on this architecture\n");
> + return TEST_SKIP;
> +#endif
Perhaps with #include <tools/config.h> the following is tidier:
if (!IS_BUILTIN(HAVE_RDTSC)) {
pr_debug("Test not supported on this architecture\n");
return TEST_SKIP;
}
> return TEST_OK;
> }
>
next prev parent reply other threads:[~2026-10-06 13:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 3:41 [PATCH v2 0/2] perf riscv: Implement rdtsc() Chen Pei
2026-09-29 3:41 ` [PATCH v2 1/2] " Chen Pei
2026-10-07 15:28 ` Paul Walmsley
2026-09-29 3:41 ` [PATCH v2 2/2] perf tsc: Declare TSC support from the build system Chen Pei
2026-09-29 9:49 ` Leo Yan
2026-10-06 13:16 ` Adrian Hunter [this message]
2026-10-07 15:31 ` Paul Walmsley
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=66136aa8-adbe-4fdf-9b7c-d44ea0e5cf1e@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=cp0613@linux.alibaba.com \
--cc=guoren@kernel.org \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®