From b5883a358b1f0bac253b12aa6aceaee2c64c7824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Bederi=C3=A1n?= Date: Wed, 12 Jul 2017 17:29:57 -0300 Subject: [PATCH] Get x86 TSC frequency from bogomips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Bederián --- opal/mca/timer/linux/timer_linux_component.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/opal/mca/timer/linux/timer_linux_component.c b/opal/mca/timer/linux/timer_linux_component.c index 15a584cd3f5..c5b664afbeb 100644 --- a/opal/mca/timer/linux/timer_linux_component.c +++ b/opal/mca/timer/linux/timer_linux_component.c @@ -134,6 +134,21 @@ static int opal_timer_linux_find_freq(void) } } +#if ((OPAL_ASSEMBLY_ARCH == OPAL_IA32) || (OPAL_ASSEMBLY_ARCH == OPAL_X86_64)) + if (0 == opal_timer_linux_freq && opal_sys_timer_is_monotonic()) { + /* tsc is exposed through bogomips ~> loops_per_jiffy ~> tsc_khz */ + loc = find_info(fp, "bogomips", buf, 1024); + if (NULL != loc) { + ret = sscanf(loc, "%f", &cpu_f); + if (1 == ret) { + /* number is in MHz * 2 and has 2 decimal digits + convert to Hz and make an integer */ + opal_timer_linux_freq = (opal_timer_t) (cpu_f * 100.0f) * 5000; + } + } + } +#endif + if (0 == opal_timer_linux_freq) { /* find the CPU speed - most timers are 1:1 with CPU speed */ loc = find_info(fp, "cpu MHz", buf, 1024);