Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Linus Torvalds
On Fri, Oct 26, 2012 at 11:14 AM, Rik van Riel wrote: > > I suspect the next context switch would flush out the TLB, > making it a slowdown, not a lockup. Common case, yes. But the page fault might happen in kernel space (due to a "put_user()" call, say), and with CONFIG_PREEMPT=n. Sure, put_use

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Rik van Riel
On 10/26/2012 02:02 PM, Linus Torvalds wrote: On Fri, Oct 26, 2012 at 10:54 AM, Rik van Riel wrote: Would tlb_fix_spurious_fault take care of that on those architectures? .. assuming that they implement it as a real TLB flush, yes. But maybe the architecture never noticed that it happened t

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Linus Torvalds
On Fri, Oct 26, 2012 at 10:54 AM, Rik van Riel wrote: > > Would tlb_fix_spurious_fault take care of that on those > architectures? .. assuming that they implement it as a real TLB flush, yes. But maybe the architecture never noticed that it happened to depend on the fact that we do a cross-CPU i

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Rik van Riel
On 10/26/2012 01:01 PM, Linus Torvalds wrote: On Fri, Oct 26, 2012 at 5:34 AM, Michel Lespinasse wrote: On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds wrote: Yes. It's not architected as far as I know, though. But I agree, it's possible - even likely - we could avoid TLB flushing entirely

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Linus Torvalds
On Fri, Oct 26, 2012 at 5:34 AM, Michel Lespinasse wrote: > On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds > wrote: >> >> Yes. It's not architected as far as I know, though. But I agree, it's >> possible - even likely - we could avoid TLB flushing entirely on x86. > > Actually, it is architecte

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Ingo Molnar
* Ingo Molnar wrote: > [...] > > Rik, mind sending an updated patch that addresses Linus's > concerns, or should I code it up if you are busy? > > We can also certainly try the second patch, but I'd do it at > the end of the series, to put some tree distance between the > two patches, to no

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Ingo Molnar
* Rik van Riel wrote: > On 10/26/2012 08:48 AM, Andi Kleen wrote: > >Michel Lespinasse writes: > > > >>On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds > >> wrote: > >>>On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: > > That may not even be needed. Apparently Intel chips > a

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Michel Lespinasse
On Fri, Oct 26, 2012 at 5:48 AM, Andi Kleen wrote: > Michel Lespinasse writes: > >> On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds >> wrote: >>> On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: That may not even be needed. Apparently Intel chips automatically flush an entry

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Rik van Riel
On 10/26/2012 08:48 AM, Andi Kleen wrote: Michel Lespinasse writes: On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds wrote: On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: That may not even be needed. Apparently Intel chips automatically flush an entry from the TLB when it causes a p

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Andi Kleen
Michel Lespinasse writes: > On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds > wrote: >> On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: >>> >>> That may not even be needed. Apparently Intel chips >>> automatically flush an entry from the TLB when it >>> causes a page fault. I assume AMD

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-26 Thread Michel Lespinasse
On Thu, Oct 25, 2012 at 9:23 PM, Linus Torvalds wrote: > On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: >> >> That may not even be needed. Apparently Intel chips >> automatically flush an entry from the TLB when it >> causes a page fault. I assume AMD chips do the same, >> because flush_t

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Ingo Molnar
* Linus Torvalds wrote: > On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: > > > > That may not even be needed. Apparently Intel chips > > automatically flush an entry from the TLB when it causes a > > page fault. I assume AMD chips do the same, because > > flush_tlb_fix_spurious_fault

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Linus Torvalds
On Thu, Oct 25, 2012 at 8:57 PM, Rik van Riel wrote: > > That may not even be needed. Apparently Intel chips > automatically flush an entry from the TLB when it > causes a page fault. I assume AMD chips do the same, > because flush_tlb_fix_spurious_fault evaluates to > nothing on x86. Yes. It's

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Rik van Riel
On 10/25/2012 10:56 PM, Linus Torvalds wrote: Guess what? If you want to optimize the function to not do remote TLB flushes, then just do that! None of the garbage. Just change the flush_tlb_page(vma, address); line to __flush_tlb_one(address); That may not even be needed. Appare

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Linus Torvalds
On Thu, Oct 25, 2012 at 7:30 PM, Rik van Riel wrote: >> >> LOOK at the code, for chrissake. Just look at it. And if you don't see >> why the above is stupid and retarded, you damn well shouldn't be >> touching VM code. > > I agree it is pretty ugly. However, the above patch > did get rid of a gig

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Rik van Riel
On 10/25/2012 04:17 PM, Linus Torvalds wrote: On Thu, Oct 25, 2012 at 5:16 AM, Peter Zijlstra wrote: From: Rik van Riel @@ -306,11 +306,26 @@ int ptep_set_access_flags(struct vm_area pte_t entry, int dirty) { int changed = !pte_same(*ptep, entry); +

Re: [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags()

2012-10-25 Thread Linus Torvalds
On Thu, Oct 25, 2012 at 5:16 AM, Peter Zijlstra wrote: > From: Rik van Riel > > @@ -306,11 +306,26 @@ int ptep_set_access_flags(struct vm_area > pte_t entry, int dirty) > { > int changed = !pte_same(*ptep, entry); > + /* > +* If the page used to be