Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 07:17 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 07:01:55PM +0100, Daniel Bristot de Oliveira wrote: >> On 11/14/2017 06:40 PM, Peter Zijlstra wrote: >>> On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: >>> IIRC, if the dest cpu is idle and

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 07:17 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 07:01:55PM +0100, Daniel Bristot de Oliveira wrote: >> On 11/14/2017 06:40 PM, Peter Zijlstra wrote: >>> On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: >>> IIRC, if the dest cpu is idle and

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 07:01:55PM +0100, Daniel Bristot de Oliveira wrote: > On 11/14/2017 06:40 PM, Peter Zijlstra wrote: > > On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > > > >> IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI > >> is fired

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 07:01:55PM +0100, Daniel Bristot de Oliveira wrote: > On 11/14/2017 06:40 PM, Peter Zijlstra wrote: > > On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > > > >> IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI > >> is fired

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 06:40 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > >> IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI >> is fired as well, but that is not a very common case. > > You're thinking about wake from

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 06:40 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > >> IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI >> is fired as well, but that is not a very common case. > > You're thinking about wake from

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI > is fired as well, but that is not a very common case. You're thinking about wake from idle? That is almost always without IPI, even without

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 06:17:13PM +0100, Daniel Bristot de Oliveira wrote: > IIRC, if the dest cpu is idle and the system is with idle=poll, no IPI > is fired as well, but that is not a very common case. You're thinking about wake from idle? That is almost always without IPI, even without

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Linus Torvalds
On Tue, Nov 14, 2017 at 9:10 AM, Mathieu Desnoyers wrote: >> (* OPTION 1 *) >> Store modified code (as data) into code segment; >> Jump to new code or an intermediate location; >> Execute new code;" > > Good point, so this is likely why I was having trouble

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Linus Torvalds
On Tue, Nov 14, 2017 at 9:10 AM, Mathieu Desnoyers wrote: >> (* OPTION 1 *) >> Store modified code (as data) into code segment; >> Jump to new code or an intermediate location; >> Execute new code;" > > Good point, so this is likely why I was having trouble reproducing the > single-threaded

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 05:31 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 08:16:09AM -0800, Andy Lutomirski wrote: >> What guarantees that there's an IPI? Do we never do a syscall, get >> migrated during syscall processing (due to cond_resched(), for >> example), and land on another CPU that just

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Daniel Bristot de Oliveira
On 11/14/2017 05:31 PM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 08:16:09AM -0800, Andy Lutomirski wrote: >> What guarantees that there's an IPI? Do we never do a syscall, get >> migrated during syscall processing (due to cond_resched(), for >> example), and land on another CPU that just

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 12:03 PM, Avi Kivity a...@scylladb.com wrote: > On 11/14/2017 06:49 PM, Mathieu Desnoyers wrote: >> - On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org >> wrote: >> >>> On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: On Tue, Nov

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 12:03 PM, Avi Kivity a...@scylladb.com wrote: > On 11/14/2017 06:49 PM, Mathieu Desnoyers wrote: >> - On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org >> wrote: >> >>> On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: On Tue, Nov

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/14/2017 06:49 PM, Mathieu Desnoyers wrote: - On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org wrote: On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: I've tried to create a small

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/14/2017 06:49 PM, Mathieu Desnoyers wrote: - On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org wrote: On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: I've tried to create a small

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org wrote: > On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: >> On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> > I've tried to create a small single-threaded self-modifying loop in >> >

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 11:08 AM, Peter Zijlstra pet...@infradead.org wrote: > On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: >> On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> > I've tried to create a small single-threaded self-modifying loop in >> >

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 08:16:09AM -0800, Andy Lutomirski wrote: > What guarantees that there's an IPI? Do we never do a syscall, get > migrated during syscall processing (due to cond_resched(), for > example), and land on another CPU that just happened to already be > scheduling? Possible, the

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 08:16:09AM -0800, Andy Lutomirski wrote: > What guarantees that there's an IPI? Do we never do a syscall, get > migrated during syscall processing (due to cond_resched(), for > example), and land on another CPU that just happened to already be > scheduling? Possible, the

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Andy Lutomirski
On Tue, Nov 14, 2017 at 8:13 AM, Thomas Gleixner wrote: > On Tue, 14 Nov 2017, Andy Lutomirski wrote: >> On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: >> > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> >> I've tried to

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Andy Lutomirski
On Tue, Nov 14, 2017 at 8:13 AM, Thomas Gleixner wrote: > On Tue, 14 Nov 2017, Andy Lutomirski wrote: >> On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: >> > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> >> I've tried to create a small single-threaded

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Thomas Gleixner
On Tue, 14 Nov 2017, Andy Lutomirski wrote: > On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: > > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > >> I've tried to create a small single-threaded self-modifying loop in > >> user-space to trigger a

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Thomas Gleixner
On Tue, 14 Nov 2017, Andy Lutomirski wrote: > On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: > > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > >> I've tried to create a small single-threaded self-modifying loop in > >> user-space to trigger a trace cache or

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Andy Lutomirski
On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> I've tried to create a small single-threaded self-modifying loop in >> user-space to trigger a trace cache or speculative execution quirk, >> but I

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Andy Lutomirski
On Tue, Nov 14, 2017 at 8:05 AM, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: >> I've tried to create a small single-threaded self-modifying loop in >> user-space to trigger a trace cache or speculative execution quirk, >> but I have not succeeded

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > > I've tried to create a small single-threaded self-modifying loop in > > user-space to trigger a trace cache or speculative execution quirk, > > but I have not

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 05:05:41PM +0100, Peter Zijlstra wrote: > On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > > I've tried to create a small single-threaded self-modifying loop in > > user-space to trigger a trace cache or speculative execution quirk, > > but I have not

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > I've tried to create a small single-threaded self-modifying loop in > user-space to trigger a trace cache or speculative execution quirk, > but I have not succeeded yet. I suspect that I would need to know > more about the

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Peter Zijlstra
On Tue, Nov 14, 2017 at 03:17:12PM +, Mathieu Desnoyers wrote: > I've tried to create a small single-threaded self-modifying loop in > user-space to trigger a trace cache or speculative execution quirk, > but I have not succeeded yet. I suspect that I would need to know > more about the

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/14/2017 05:17 PM, Mathieu Desnoyers wrote: - On Nov 14, 2017, at 9:53 AM, Avi Kivity a...@scylladb.com wrote: On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: - On Nov 10, 2017, at

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/14/2017 05:17 PM, Mathieu Desnoyers wrote: - On Nov 14, 2017, at 9:53 AM, Avi Kivity a...@scylladb.com wrote: On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: - On Nov 10, 2017, at

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 9:53 AM, Avi Kivity a...@scylladb.com wrote: > On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: >> - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers >> mathieu.desnoy...@efficios.com wrote: >> >>> - On Nov 10, 2017, at 4:36 PM, Linus Torvalds >>>

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Mathieu Desnoyers
- On Nov 14, 2017, at 9:53 AM, Avi Kivity a...@scylladb.com wrote: > On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: >> - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers >> mathieu.desnoy...@efficios.com wrote: >> >>> - On Nov 10, 2017, at 4:36 PM, Linus Torvalds >>>

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: - On Nov 10, 2017, at 4:36 PM, Linus Torvalds torva...@linux-foundation.org wrote: On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-14 Thread Avi Kivity
On 11/13/2017 06:56 PM, Mathieu Desnoyers wrote: - On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: - On Nov 10, 2017, at 4:36 PM, Linus Torvalds torva...@linux-foundation.org wrote: On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers wrote:

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-13 Thread Linus Torvalds
On Mon, Nov 13, 2017 at 8:56 AM, Mathieu Desnoyers wrote: > > I figured out what you're pointing to: if exec() is executed by a previously > running thread, and there is no core serializing instruction between program > load and return to user-space, the kernel

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-13 Thread Linus Torvalds
On Mon, Nov 13, 2017 at 8:56 AM, Mathieu Desnoyers wrote: > > I figured out what you're pointing to: if exec() is executed by a previously > running thread, and there is no core serializing instruction between program > load and return to user-space, the kernel ends up acting like a JIT, indeed.

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-13 Thread Mathieu Desnoyers
- On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: > - On Nov 10, 2017, at 4:36 PM, Linus Torvalds > torva...@linux-foundation.org > wrote: > >> On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers >> wrote: >>> x86 can

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-13 Thread Mathieu Desnoyers
- On Nov 10, 2017, at 4:57 PM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote: > - On Nov 10, 2017, at 4:36 PM, Linus Torvalds > torva...@linux-foundation.org > wrote: > >> On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers >> wrote: >>> x86 can return to user-space through

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Linus Torvalds
On Fri, Nov 10, 2017 at 1:57 PM, Mathieu Desnoyers wrote: > > That core serializing instruction is not that much about I$ vs D$ > consistency, but rather about the processor speculatively executing code > ahead of its retirement point. Ref. Intel Architecture

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Linus Torvalds
On Fri, Nov 10, 2017 at 1:57 PM, Mathieu Desnoyers wrote: > > That core serializing instruction is not that much about I$ vs D$ > consistency, but rather about the processor speculatively executing code > ahead of its retirement point. Ref. Intel Architecture Software Developer's > Manual, Volume

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Mathieu Desnoyers
- On Nov 10, 2017, at 4:36 PM, Linus Torvalds torva...@linux-foundation.org wrote: > On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers > wrote: >> x86 can return to user-space through sysexit and sysretq, which are not >> core serializing. This breaks

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Mathieu Desnoyers
- On Nov 10, 2017, at 4:36 PM, Linus Torvalds torva...@linux-foundation.org wrote: > On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers > wrote: >> x86 can return to user-space through sysexit and sysretq, which are not >> core serializing. This breaks expectations from user-space about >>

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Linus Torvalds
On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers wrote: > x86 can return to user-space through sysexit and sysretq, which are not > core serializing. This breaks expectations from user-space about > sequential consistency from a single-threaded self-modifying

Re: [RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Linus Torvalds
On Fri, Nov 10, 2017 at 1:12 PM, Mathieu Desnoyers wrote: > x86 can return to user-space through sysexit and sysretq, which are not > core serializing. This breaks expectations from user-space about > sequential consistency from a single-threaded self-modifying program > point of view in specific

[RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Mathieu Desnoyers
x86 can return to user-space through sysexit and sysretq, which are not core serializing. This breaks expectations from user-space about sequential consistency from a single-threaded self-modifying program point of view in specific migration patterns. Feedback is welcome, Thanks, Mathieu

[RFC PATCH 0/2] x86: Fix missing core serialization on migration

2017-11-10 Thread Mathieu Desnoyers
x86 can return to user-space through sysexit and sysretq, which are not core serializing. This breaks expectations from user-space about sequential consistency from a single-threaded self-modifying program point of view in specific migration patterns. Feedback is welcome, Thanks, Mathieu