diff options
author | Nicolas Saenz Julienne <nsaenzju@redhat.com> | 2021-09-13 10:39:08 +0200 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2021-09-13 14:37:05 -0400 |
commit | 8cb3f6d295e9fa152b4f84d4641a3bff813b08ba (patch) | |
tree | c66af07f3f17641ae96025c7c6e605e8b96004ce | |
parent | 7d42e803ec498595850b6f52f57475fba81e1fa0 (diff) | |
download | rt-tests-8cb3f6d295e9fa152b4f84d4641a3bff813b08ba.tar.gz |
oslat: Allow for arch specific counter frequency measurements
Some architectures have special purpose registers to query the system
counter's frequency. Let's use that when available.
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
--
Changes since v1:
- Use cleaner method to have generic and arch functions to measure
couter's freq
src/oslat/oslat.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/oslat/oslat.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c index c90ec1a..5fce223 100644 --- a/src/oslat/oslat.c +++ b/src/oslat/oslat.c @@ -74,6 +74,16 @@ static inline void frc(uint64_t *pval) # elif defined(__aarch64__) # define relax() __asm__ __volatile("yield" : : : "memory") +#define arch_measure_counter_mhz +static unsigned int measure_counter_mhz(void) +{ + unsigned int val; + + __asm__ __volatile__("mrs %0, cntfrq_el0" : "=r" (val)); + + return val / 1e6; +} + static inline void frc(uint64_t *pval) { /* @@ -241,6 +251,7 @@ static int move_to_core(int core_i) return sched_setaffinity(0, sizeof(cpus), &cpus); } +#ifndef arch_measure_counter_mhz static cycles_t __measure_counter_hz(void) { struct timeval tvs, tve; @@ -273,6 +284,7 @@ static unsigned int measure_counter_mhz(void) return (unsigned int) (m / 1000000); } +#endif static void thread_init(struct thread *t) { |