trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86
PATCH 1/1 trace-cmd: Fix trace_tsc2nsec_is_supported() on !x86
'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().
--- tracecmd/trace-record.c | 3 +++ 1 file changed, 3 insertions(+)
tracecmd/trace-record.c +3 -0
@@ -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 ; }
Signature · 1 line
2.33.1
Quoted 3 lines · On Tue, 16 Nov 2021 20:21:52 +0100 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().
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
Quoted 20 lines
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- tracecmd/trace-record.c | 3 +++ 1 file changed, 3 insertions(+)tracecmd/trace-record.c +3
-0@@ -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 ; }