* [PATCH] trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86
@ 2021-11-16 19:21 Nicolas Saenz Julienne
2021-11-16 19:50 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Saenz Julienne @ 2021-11-16 19:21 UTC (permalink / raw)
To: linux-trace-devel; +Cc: tz.stoyanov, rostedt, Nicolas Saenz Julienne
'trace-cmd list -C' outputs 'tsc2nsec' on my arm64 machine. TSC is an
x86 specific counter, so it shouldn't be supported. Fix this by making
sure TSC exists as a trace clock in trace_tsc2nsec_is_supported().
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---
tracecmd/trace-record.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 1767a6c..78e9566 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -6122,6 +6122,9 @@ static int get_tsc_nsec(int *shift, int *mult)
bool trace_tsc2nsec_is_supported(void)
{
+ if (!clock_is_supported(NULL, TSC_CLOCK))
+ return false;
+
return get_tsc_nsec(NULL, NULL) == 0;
}
--
2.33.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86
2021-11-16 19:21 [PATCH] trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86 Nicolas Saenz Julienne
@ 2021-11-16 19:50 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2021-11-16 19:50 UTC (permalink / raw)
To: Nicolas Saenz Julienne; +Cc: linux-trace-devel, tz.stoyanov
On Tue, 16 Nov 2021 20:21:52 +0100
Nicolas Saenz Julienne <nsaenzju@redhat.com> wrote:
> 'trace-cmd list -C' outputs 'tsc2nsec' on my arm64 machine. TSC is an
> x86 specific counter, so it shouldn't be supported. Fix this by making
> sure TSC exists as a trace clock in trace_tsc2nsec_is_supported().
TSC is just an acronym for Time Stamp Counter. Yes, x86 calls it the TSC,
but really it can be any raw clock.
If arm or any other arch has a raw clock that can write directly to the
ring buffer, and perf has a way to convert that to nsecs, we should still
be able to support it. For instance, I believe that powerpc has a ppc-tb
clock that is similar to the tsc of x86. We probably should allow that too.
Hmm, I wonder if the kernel should have a "raw_clock" if the raw time stamp
is used for any arch, and the tsc2nsec can still be used if raw_clock is
supported.
That said, I agree that we should verify that the raw clock that is
converted is available along with the perf info.
-- Steve
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
> ---
> tracecmd/trace-record.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 1767a6c..78e9566 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -6122,6 +6122,9 @@ static int get_tsc_nsec(int *shift, int *mult)
>
> bool trace_tsc2nsec_is_supported(void)
> {
> + if (!clock_is_supported(NULL, TSC_CLOCK))
> + return false;
> +
> return get_tsc_nsec(NULL, NULL) == 0;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-16 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 19:21 [PATCH] trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86 Nicolas Saenz Julienne
2021-11-16 19:50 ` Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.