Re: [PATCH] x86/TSC: Use RDTSCP

2018-12-07 Thread Borislav Petkov
Ok, I have something which looks like it works here, even with the pentium3 qemu CPU. I'll be hammering on it in the coming days but if you wanna give it a try, here's a conglomerate patch: --- >From 0c6adce02d2e7f3b5bbdc4cbe3eb3dae99448def Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Fr

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread Borislav Petkov
On Fri, Nov 23, 2018 at 01:03:25PM -0800, Guenter Roeck wrote: > It is a cut off screen log. x86 boots change xterm configuration from > wrap to non-wrap, and I did a cut-and-paste instead of copying the log > to a file. Sorry for that. No worries. It was a head-scratcher though because look what

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread Guenter Roeck
On 11/23/18 12:44 PM, Borislav Petkov wrote: On Fri, Nov 23, 2018 at 12:03:07PM -0800, Guenter Roeck wrote: [0.762832] EIP: read_tsc+0x4/0x10 [0.762832] Code: 00 01 00 eb 89 90 55 89 e5 5d c3 90 90 90 90 90 90 90 90 90 90 90 55 a1 44 5a 8b c5 89 e5 5d c3 8d b6 00 00 00 00 55 89 e5 57 <0

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread Borislav Petkov
On Fri, Nov 23, 2018 at 12:03:07PM -0800, Guenter Roeck wrote: > [0.762832] EIP: read_tsc+0x4/0x10 > [0.762832] Code: 00 01 00 eb 89 90 55 89 e5 5d c3 90 90 90 90 90 90 90 90 > 90 90 90 55 a1 44 5a 8b c5 89 e5 5d c3 8d b6 00 00 00 00 55 89 e5 57 <0f> ae > f0b Where does that 'b' in f0b c

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread Thomas Gleixner
On Fri, 23 Nov 2018, h...@zytor.com wrote: > On November 23, 2018 12:03:07 PM PST, Guenter Roeck > wrote: > ># first bad commit: [2e94061096c5c3aa6c3fe3ec2bec176c1f9c1b07] x86/TSC: > >Use RDTSCP > > Right, because that cpu predates RDTSCP, so it needs to use a fallback. Well, that's not the pro

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread hpa
On November 23, 2018 12:03:07 PM PST, Guenter Roeck wrote: >Hi, > >On Mon, Nov 19, 2018 at 07:45:56PM +0100, Borislav Petkov wrote: >> From: Borislav Petkov >> >> Currently, the kernel uses >> >> [LM]FENCE; RDTSC >> >> in the timekeeping code, to guarantee monotonicity of time where the >> *

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-23 Thread Guenter Roeck
Hi, On Mon, Nov 19, 2018 at 07:45:56PM +0100, Borislav Petkov wrote: > From: Borislav Petkov > > Currently, the kernel uses > > [LM]FENCE; RDTSC > > in the timekeeping code, to guarantee monotonicity of time where the > *FENCE is selected based on vendor. > > Replace that sequence with RDTS

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread hpa
On November 19, 2018 12:40:25 PM PST, Borislav Petkov wrote: >On Mon, Nov 19, 2018 at 12:17:35PM -0800, H. Peter Anvin wrote: >> On 11/19/18 11:52 AM, Andy Lutomirski wrote: >> > >> > I thought I benchmarked this on Intel at some point and found the >> > LFENCE;RDTSC variant to be slightly faster

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread Borislav Petkov
On Mon, Nov 19, 2018 at 12:17:35PM -0800, H. Peter Anvin wrote: > On 11/19/18 11:52 AM, Andy Lutomirski wrote: > > > > I thought I benchmarked this on Intel at some point and found the > > LFENCE;RDTSC variant to be slightly faster. But I believe you, so: > > > > Acked-by: Andy Lutomirski > >

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread H. Peter Anvin
On 11/19/18 11:52 AM, Andy Lutomirski wrote: > > I thought I benchmarked this on Intel at some point and found the > LFENCE;RDTSC variant to be slightly faster. But I believe you, so: > > Acked-by: Andy Lutomirski > As long as the difference isn't significant, the simplicity would seem to be

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread Andy Lutomirski
On Mon, Nov 19, 2018 at 10:46 AM Borislav Petkov wrote: > > From: Borislav Petkov > > Currently, the kernel uses > > [LM]FENCE; RDTSC > > in the timekeeping code, to guarantee monotonicity of time where the > *FENCE is selected based on vendor. > > Replace that sequence with RDTSCP which is fas

Re: [PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread Lendacky, Thomas
On 11/19/2018 12:45 PM, Borislav Petkov wrote: > From: Borislav Petkov > > Currently, the kernel uses > > [LM]FENCE; RDTSC > > in the timekeeping code, to guarantee monotonicity of time where the > *FENCE is selected based on vendor. > > Replace that sequence with RDTSCP which is faster or o

[PATCH] x86/TSC: Use RDTSCP

2018-11-19 Thread Borislav Petkov
From: Borislav Petkov Currently, the kernel uses [LM]FENCE; RDTSC in the timekeeping code, to guarantee monotonicity of time where the *FENCE is selected based on vendor. Replace that sequence with RDTSCP which is faster or on-par and gives the same guarantees. A microbenchmark on Intel sho