Skip to content

Conversation

@jty2
Copy link
Contributor

@jty2 jty2 commented Jun 11, 2025

Always measure TSC frequency on x86

This patch corrects duration calculations and timings on x86 involving the TSC by measuring its frequency for 3x 0.1 seconds on every run of the program. This fixes #86 so that --hwtimer-freq is not needed to get a correct measurement.

Other patches included:
Makefile: improve Jansson-is-missing error handling
include/perf_timer.h: fix rdtscp register clobber list

jty2 added 3 commits June 10, 2025 22:38
Rather than letting the compiler fail due to the Jansson header file
missing, check if it is installed, and, if it is not, provide an
informative error message for installing it or building without it.

Change-Id: I6bf6195e9c27faa6096a3ca41223c41a4da8c6c5
Signed-off-by: jty2 <46021128+jty2@users.noreply.github.com>
rdtscp also writes to the ECX register.  Fix clobber list so that
register allocation is done correctly by the compiler.

Change-Id: Ie3c6a5ab8fbeae46605642fc7971b0e1504dd7c2
Signed-off-by: jty2 <46021128+jty2@users.noreply.github.com>
The TSC frequency is not easy to obtain.  The methods that this patch
replace do not always work.  However, the TSC frequency is used for
blackhole and test durations, so an accurate number is important.

This patch improves the TSC frequency measurement routine to support
sub-second samples.  On every run of the program, the frequency is
measured for 3 samples of 0.1 seconds, dropping the highest and lowest.

Change-Id: Ifc62210b8da586fbaebf0a3f22d72bc2eebda92b
Signed-off-by: jty2 <46021128+jty2@users.noreply.github.com>
@jty2 jty2 merged commit 1830928 into ARM-software:master Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TSC hardware timer frequency on x86 is usually wrong

1 participant