Re: [PATCH] x86/mm: disable preemption during CR3 read+write

2016-08-05 Thread Sebastian Andrzej Siewior
On 08/05/2016 05:42 PM, Andy Lutomirski wrote: > > This should affect kernel threads too, right? I don't think so because they don't have a MM in the first place so they don't shouldn't need to flush a TLB. But then there is iounmap() and vfree() for instance which does vmap_debug_free_range() {

Re: [PATCH] x86/mm: disable preemption during CR3 read+write

2016-08-05 Thread Andy Lutomirski
On Fri, Aug 5, 2016 at 6:37 AM, Sebastian Andrzej Siewior wrote: > Usually current->mm (and therefore mm->pgd) stays the same during the > lifetime of a task so it does not matter if a task gets preempted during > the read and write of the CR3. > > But then, there is this scenario on x86-UP: > Tas

Re: [PATCH] x86/mm: disable preemption during CR3 read+write

2016-08-05 Thread Rik van Riel
On Fri, 2016-08-05 at 15:37 +0200, Sebastian Andrzej Siewior wrote: >  > +++ b/arch/x86/include/asm/tlbflush.h > @@ -135,7 +135,14 @@ static inline void > cr4_set_bits_and_update_boot(unsigned long mask) >   >  static inline void __native_flush_tlb(void) >  { > + /* > +  * if current->mm ==

Re: [PATCH] x86/mm: disable preemption during CR3 read+write

2016-08-05 Thread Peter Zijlstra
On Fri, Aug 05, 2016 at 03:37:39PM +0200, Sebastian Andrzej Siewior wrote: > diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h > index 4e5be94e079a..1ee065954e24 100644 > --- a/arch/x86/include/asm/tlbflush.h > +++ b/arch/x86/include/asm/tlbflush.h > @@ -135,7 +135,14 @

[PATCH] x86/mm: disable preemption during CR3 read+write

2016-08-05 Thread Sebastian Andrzej Siewior
Usually current->mm (and therefore mm->pgd) stays the same during the lifetime of a task so it does not matter if a task gets preempted during the read and write of the CR3. But then, there is this scenario on x86-UP: TaskA is in do_exit() and exit_mm() sets current->mm = NULL followed by mmput()