diff mbox series

[v4,2/3] x86/time: yield to hyperthreads after updating TSC during rendezvous

Message ID 81da85eb-2e8e-9b76-2fb3-2beddc33e9af@suse.com (mailing list archive)
State New, archived
Headers show
Series x86/time: calibration rendezvous adjustments | expand

Commit Message

Jan Beulich April 1, 2021, 9:54 a.m. UTC
Since we'd like the updates to be done as synchronously as possible,
make an attempt at yielding immediately after the TSC write.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v4: New.

Comments

Roger Pau Monne April 20, 2021, 3:59 p.m. UTC | #1
On Thu, Apr 01, 2021 at 11:54:27AM +0200, Jan Beulich wrote:
> Since we'd like the updates to be done as synchronously as possible,
> make an attempt at yielding immediately after the TSC write.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Did you observe any difference with the pause inserted?

I wonder whether that's enough to give a chance the hyperthread to
also perform the TSC write. In any case there's no harm from it
certainly.

Thanks, Roger.
Jan Beulich April 21, 2021, 9:57 a.m. UTC | #2
On 20.04.2021 17:59, Roger Pau Monné wrote:
> On Thu, Apr 01, 2021 at 11:54:27AM +0200, Jan Beulich wrote:
>> Since we'd like the updates to be done as synchronously as possible,
>> make an attempt at yielding immediately after the TSC write.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

> Did you observe any difference with the pause inserted?

I wouldn't even know how to measure it precisely enough. So - no,
I haven't. In fact ...

> I wonder whether that's enough to give a chance the hyperthread to
> also perform the TSC write. In any case there's no harm from it
> certainly.

... I have an inquiry pending with Intel as to better (more
reliable) ways to yield, for quite a bit longer than the 8259 one,
yet with the same lack of any outcome so far. Until then it really
is going to be no more than "make an attempt", as said in the
commit message.

Jan
diff mbox series

Patch

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1708,7 +1708,14 @@  static void time_calibration_tsc_rendezv
             atomic_inc(&r->semaphore);
 
             if ( i == 0 )
+            {
                 write_tsc(master_tsc);
+                /*
+                 * Try to give our hyperthread(s), if any, a chance to do
+                 * the same as instantly as possible.
+                 */
+                cpu_relax();
+            }
 
             while ( atomic_read(&r->semaphore) != (2*total_cpus - 1) )
                 cpu_relax();
@@ -1730,7 +1737,14 @@  static void time_calibration_tsc_rendezv
             }
 
             if ( i == 0 )
+            {
                 write_tsc(master_tsc);
+                /*
+                 * Try to give our hyperthread(s), if any, a chance to do
+                 * the same as instantly as possible.
+                 */
+                cpu_relax();
+            }
 
             atomic_inc(&r->semaphore);
             while ( atomic_read(&r->semaphore) > total_cpus )