Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-31 Thread Peter Zijlstra
On Thu, Aug 31, 2017 at 12:25:16PM +0530, Anshuman Khandual wrote: > On 08/30/2017 03:02 PM, Laurent Dufour wrote: > > On 30/08/2017 07:58, Peter Zijlstra wrote: > >> On Wed, Aug 30, 2017 at 10:33:50AM +0530, Anshuman Khandual wrote: > >>> diff --git a/mm/filemap.c b/mm/filemap.c > >>> index a49702

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-30 Thread Anshuman Khandual
On 08/30/2017 03:02 PM, Laurent Dufour wrote: > On 30/08/2017 07:58, Peter Zijlstra wrote: >> On Wed, Aug 30, 2017 at 10:33:50AM +0530, Anshuman Khandual wrote: >>> diff --git a/mm/filemap.c b/mm/filemap.c >>> index a497024..08f3042 100644 >>> --- a/mm/filemap.c >>> +++ b/mm/filemap.c >>> @@ -1181,

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-30 Thread Laurent Dufour
On 30/08/2017 07:03, Anshuman Khandual wrote: > On 08/29/2017 07:15 PM, Peter Zijlstra wrote: >> On Tue, Aug 29, 2017 at 03:18:25PM +0200, Laurent Dufour wrote: >>> On 29/08/2017 14:04, Peter Zijlstra wrote: On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: > On 27/08/2017 02

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-30 Thread Laurent Dufour
On 30/08/2017 07:58, Peter Zijlstra wrote: > On Wed, Aug 30, 2017 at 10:33:50AM +0530, Anshuman Khandual wrote: >> diff --git a/mm/filemap.c b/mm/filemap.c >> index a497024..08f3042 100644 >> --- a/mm/filemap.c >> +++ b/mm/filemap.c >> @@ -1181,6 +1181,18 @@ int __lock_page_killable(struct page *__

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-30 Thread Laurent Dufour
On 27/08/2017 02:18, Kirill A. Shutemov wrote: > On Fri, Aug 18, 2017 at 12:05:13AM +0200, Laurent Dufour wrote: >> +/* >> + * vm_normal_page() adds some processing which should be done while >> + * hodling the mmap_sem. >> + */ >> +int handle_speculative_fault(struct mm_struct *mm, unsigned long a

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Wed, Aug 30, 2017 at 07:19:30AM +1000, Benjamin Herrenschmidt wrote: > On Tue, 2017-08-29 at 13:27 +0200, Peter Zijlstra wrote: > > mpe helped me out and explained that is the PWC hint to TBLIE. > > > > So, you set need_flush_all when you unhook pud/pmd/pte which you then > > use to set PWC. So

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Wed, Aug 30, 2017 at 10:33:50AM +0530, Anshuman Khandual wrote: > diff --git a/mm/filemap.c b/mm/filemap.c > index a497024..08f3042 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -1181,6 +1181,18 @@ int __lock_page_killable(struct page *__page) > int __lock_page_or_retry(struct page *pag

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Anshuman Khandual
On 08/27/2017 05:48 AM, Kirill A. Shutemov wrote: >> +/* Transparent huge pages are not supported. */ >> +if (unlikely(pmd_trans_huge(*pmd))) >> +goto out_walk; > That's looks like a blocker to me. > > Is there any problem with making it supported (besides plain coding)? IIUC

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Anshuman Khandual
On 08/29/2017 07:15 PM, Peter Zijlstra wrote: > On Tue, Aug 29, 2017 at 03:18:25PM +0200, Laurent Dufour wrote: >> On 29/08/2017 14:04, Peter Zijlstra wrote: >>> On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: On 27/08/2017 02:18, Kirill A. Shutemov wrote: >> + >> +

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Anshuman Khandual
On 08/29/2017 05:34 PM, Peter Zijlstra wrote: > On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: >> On 27/08/2017 02:18, Kirill A. Shutemov wrote: + + if (unlikely(!vma->anon_vma)) + goto unlock; >>> It deserves a comment. >> You're right I'll add it in the n

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Benjamin Herrenschmidt
On Tue, 2017-08-29 at 13:27 +0200, Peter Zijlstra wrote: > mpe helped me out and explained that is the PWC hint to TBLIE. > > So, you set need_flush_all when you unhook pud/pmd/pte which you then > use to set PWC. So free_pgtables() will do the PWC when it unhooks > higher level pages. > > But yo

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Tue, Aug 29, 2017 at 03:18:25PM +0200, Laurent Dufour wrote: > On 29/08/2017 14:04, Peter Zijlstra wrote: > > On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: > >> On 27/08/2017 02:18, Kirill A. Shutemov wrote: > + > +if (unlikely(!vma->anon_vma)) > +

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Laurent Dufour
On 29/08/2017 14:04, Peter Zijlstra wrote: > On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: >> On 27/08/2017 02:18, Kirill A. Shutemov wrote: + + if (unlikely(!vma->anon_vma)) + goto unlock; >>> >>> It deserves a comment. >> >> You're right I'll add it in t

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Tue, Aug 29, 2017 at 09:59:30AM +0200, Laurent Dufour wrote: > On 27/08/2017 02:18, Kirill A. Shutemov wrote: > >> + > >> + if (unlikely(!vma->anon_vma)) > >> + goto unlock; > > > > It deserves a comment. > > You're right I'll add it in the next version. > For the record, the root ca

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Tue, Aug 29, 2017 at 10:33:52AM +0200, Peter Zijlstra wrote: > On Tue, Aug 29, 2017 at 07:14:37AM +1000, Benjamin Herrenschmidt wrote: > > We'd have to audit archs closely. Things like the page walk cache > > flushing on power etc... > > If you point me where to look, I'll have a poke around. I

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Tue, Aug 29, 2017 at 07:14:37AM +1000, Benjamin Herrenschmidt wrote: > On Mon, 2017-08-28 at 11:37 +0200, Peter Zijlstra wrote: > > > Doing all this job and just give up because we cannot allocate page tables > > > looks very wasteful to me. > > > > > > Have you considered to look how we can ha

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Peter Zijlstra
On Mon, Aug 28, 2017 at 03:35:11PM -0700, Andi Kleen wrote: > Yes the whole thing is quite risky. Probably will need some > kind of per architecture opt-in scheme? See patch 19/20, that not enough for you?

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-29 Thread Laurent Dufour
On 27/08/2017 02:18, Kirill A. Shutemov wrote: > On Fri, Aug 18, 2017 at 12:05:13AM +0200, Laurent Dufour wrote: >> +/* >> + * vm_normal_page() adds some processing which should be done while >> + * hodling the mmap_sem. >> + */ >> +int handle_speculative_fault(struct mm_struct *mm, unsigned long a

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-28 Thread Andi Kleen
> That makes me extremely nervous... there could be all sort of > assumptions esp. in arch code about the fact that we never populate the > tree without the mm sem. > > We'd have to audit archs closely. Things like the page walk cache > flushing on power etc... Yes the whole thing is quite risky.

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-28 Thread Benjamin Herrenschmidt
On Mon, 2017-08-28 at 11:37 +0200, Peter Zijlstra wrote: > > Doing all this job and just give up because we cannot allocate page tables > > looks very wasteful to me. > > > > Have you considered to look how we can hand over from speculative to > > non-speculative path without starting from scratch

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-28 Thread Peter Zijlstra
On Sun, Aug 27, 2017 at 03:18:23AM +0300, Kirill A. Shutemov wrote: > On Fri, Aug 18, 2017 at 12:05:13AM +0200, Laurent Dufour wrote: > > + /* > > +* Can't call vm_ops service has we don't know what they would do > > +* with the VMA. > > +* This include huge page from hugetlbfs. > > +

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-26 Thread Kirill A. Shutemov
On Fri, Aug 18, 2017 at 12:05:13AM +0200, Laurent Dufour wrote: > +/* > + * vm_normal_page() adds some processing which should be done while > + * hodling the mmap_sem. > + */ > +int handle_speculative_fault(struct mm_struct *mm, unsigned long address, > + unsigned int flag

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-25 Thread Laurent Dufour
On 20/08/2017 14:11, Sergey Senozhatsky wrote: > On (08/18/17 00:05), Laurent Dufour wrote: > [..] >> +/* >> + * MPOL_INTERLEAVE implies additional check in mpol_misplaced() which >> + * are not compatible with the speculative page fault processing. >> + */ >> +pol = __get_vma_p

Re: [PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-20 Thread Sergey Senozhatsky
On (08/18/17 00:05), Laurent Dufour wrote: [..] > + /* > + * MPOL_INTERLEAVE implies additional check in mpol_misplaced() which > + * are not compatible with the speculative page fault processing. > + */ > + pol = __get_vma_policy(vma, address); > + if (!pol) > +

[PATCH v2 14/20] mm: Provide speculative fault infrastructure

2017-08-17 Thread Laurent Dufour
From: Peter Zijlstra Provide infrastructure to do a speculative fault (not holding mmap_sem). The not holding of mmap_sem means we can race against VMA change/removal and page-table destruction. We use the SRCU VMA freeing to keep the VMA around. We use the VMA seqcount to detect change (includi