[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/time: avoid reading the platform timer in rendezvous functions
commit 48bb237fca65e2bcec7dbe7f4b178cf33c5e15f0 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue May 4 10:49:59 2021 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue May 4 10:49:59 2021 +0200 x86/time: avoid reading the platform timer in rendezvous functions Reading the platform timer isn't cheap, so we'd better avoid it when the resulting value is of no interest to anyone. The consumer of master_stime, obtained by time_calibration_{std,tsc}_rendezvous() and propagated through this_cpu(cpu_calibration), is local_time_calibration(). With CONSTANT_TSC the latter function uses an early exit path, which doesn't explicitly use the field. While this_cpu(cpu_calibration) (including the master_stime field) gets propagated to this_cpu(cpu_time).stamp on that path, both structures' fields get consumed only by the !CONSTANT_TSC logic of the function. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/time.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 5578b7b3a2..10418cdc54 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -52,6 +52,7 @@ unsigned long pit0_ticks; struct cpu_time_stamp { u64 local_tsc; s_time_t local_stime; + /* Next field unconditionally valid only when !CONSTANT_TSC. */ s_time_t master_stime; }; @@ -1702,7 +1703,7 @@ static void time_calibration_tsc_rendezvous(void *_r) * iteration. */ r->master_tsc_stamp = r->max_tsc_stamp; - else if ( i == 0 ) + else if ( !boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && i == 0 ) r->master_stime = read_platform_stime(NULL); atomic_inc(&r->semaphore); @@ -1776,8 +1777,11 @@ static void time_calibration_std_rendezvous(void *_r) { while ( atomic_read(&r->semaphore) != (total_cpus - 1) ) cpu_relax(); - r->master_stime = read_platform_stime(NULL); - smp_wmb(); /* write r->master_stime /then/ signal */ + if ( !boot_cpu_has(X86_FEATURE_CONSTANT_TSC) ) + { + r->master_stime = read_platform_stime(NULL); + smp_wmb(); /* write r->master_stime /then/ signal */ + } atomic_inc(&r->semaphore); } else -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |