Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-18 Thread Jason Gunthorpe
On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: > On 9/28/21 19:01, Jason Gunthorpe wrote: > > On Thu, Sep 23, 2021 at 05:51:04PM +0100, Joao Martins wrote: > >> So ... if pgmap accounting was removed from gup-fast then this patch > >> would be a lot simpler and we could perhaps just

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-18 Thread Jason Gunthorpe
On Thu, Sep 30, 2021 at 01:01:14PM +1000, Alistair Popple wrote: > On Thursday, 30 September 2021 5:34:05 AM AEST Jason Gunthorpe wrote: > > On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: > > > > > > If the get_dev_pagemap has to remain then it just means we have to > > > > flush be

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-14 Thread Jason Gunthorpe
On Thu, Oct 14, 2021 at 06:56:51PM +0100, Joao Martins wrote: > > And I would document this relationship in the GUP side "This do/while > > is required because insert_pfn_pmd/pud() is used with compound pages > > smaller than the PUD/PMD size" so it isn't so confused with just > > "devmap" > > Al

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-14 Thread Joao Martins
On 10/13/21 20:43, Jason Gunthorpe wrote: > On Wed, Oct 13, 2021 at 08:18:08PM +0100, Joao Martins wrote: >> On 10/13/21 18:41, Jason Gunthorpe wrote: >>> On Mon, Oct 11, 2021 at 04:53:29PM +0100, Joao Martins wrote: On 10/8/21 12:54, Jason Gunthorpe wrote: >>> > The only optimization that

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-13 Thread Jason Gunthorpe
On Wed, Oct 13, 2021 at 08:18:08PM +0100, Joao Martins wrote: > On 10/13/21 18:41, Jason Gunthorpe wrote: > > On Mon, Oct 11, 2021 at 04:53:29PM +0100, Joao Martins wrote: > >> On 10/8/21 12:54, Jason Gunthorpe wrote: > > > >>> The only optimization that might work here is to grab the head, then >

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-13 Thread Joao Martins
On 10/13/21 18:41, Jason Gunthorpe wrote: > On Mon, Oct 11, 2021 at 04:53:29PM +0100, Joao Martins wrote: >> On 10/8/21 12:54, Jason Gunthorpe wrote: > >>> The only optimization that might work here is to grab the head, then >>> compute the extent of tail pages and amalgamate them. Holding a ref o

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-13 Thread Jason Gunthorpe
On Mon, Oct 11, 2021 at 04:53:29PM +0100, Joao Martins wrote: > On 10/8/21 12:54, Jason Gunthorpe wrote: > > The only optimization that might work here is to grab the head, then > > compute the extent of tail pages and amalgamate them. Holding a ref on > > the head also secures the tails. > > How

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-11 Thread Joao Martins
On 10/8/21 12:54, Jason Gunthorpe wrote: > On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: >> @@ -2252,16 +2265,25 @@ static int __gup_device_huge(unsigned long pfn, >> unsigned long addr, >> ret = 0; >> break; >> } >> -

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-10-08 Thread Jason Gunthorpe
On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: > @@ -2252,16 +2265,25 @@ static int __gup_device_huge(unsigned long pfn, > unsigned long addr, > ret = 0; > break; > } > - SetPageReferenced(page); > - p

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-30 Thread Jason Gunthorpe
On Thu, Sep 30, 2021 at 06:54:05PM +0100, Joao Martins wrote: > On 9/30/21 04:01, Alistair Popple wrote: > > On Thursday, 30 September 2021 5:34:05 AM AEST Jason Gunthorpe wrote: > >> On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: > >> > If the get_dev_pagemap has to remain then

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-30 Thread Joao Martins
On 9/30/21 04:01, Alistair Popple wrote: > On Thursday, 30 September 2021 5:34:05 AM AEST Jason Gunthorpe wrote: >> On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: >> If the get_dev_pagemap has to remain then it just means we have to flush before changing pagemap pointers >>

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-29 Thread Alistair Popple
On Thursday, 30 September 2021 5:34:05 AM AEST Jason Gunthorpe wrote: > On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: > > > > If the get_dev_pagemap has to remain then it just means we have to > > > flush before changing pagemap pointers > > Right -- I don't think we should need it

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-29 Thread Jason Gunthorpe
On Wed, Sep 29, 2021 at 12:50:15PM +0100, Joao Martins wrote: > > If the get_dev_pagemap has to remain then it just means we have to > > flush before changing pagemap pointers > Right -- I don't think we should need it as that discussion on the other > thread goes. > > OTOH, using @pgmap might be

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-29 Thread Joao Martins
On 9/28/21 19:01, Jason Gunthorpe wrote: > On Thu, Sep 23, 2021 at 05:51:04PM +0100, Joao Martins wrote: >> So ... if pgmap accounting was removed from gup-fast then this patch >> would be a lot simpler and we could perhaps just fallback to the regular >> hugepage case (THP, HugeTLB) like your sugg

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 23, 2021 at 05:51:04PM +0100, Joao Martins wrote: > On 8/31/21 6:05 PM, Jason Gunthorpe wrote: > >> Switching to similar iteration logic to unpin would look something like > >> this (still untested): > >> > >> for_each_compound_range(index, &page, npages, head, refs) { > >>

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-09-23 Thread Joao Martins
On 8/31/21 6:05 PM, Jason Gunthorpe wrote: > On Tue, Aug 31, 2021 at 01:34:04PM +0100, Joao Martins wrote: >> On 8/30/21 2:07 PM, Jason Gunthorpe wrote: >>> On Fri, Aug 27, 2021 at 07:34:54PM +0100, Joao Martins wrote: On 8/27/21 5:25 PM, Jason Gunthorpe wrote: > On Fri, Aug 27, 2021 at 03

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-31 Thread Jason Gunthorpe
On Tue, Aug 31, 2021 at 01:34:04PM +0100, Joao Martins wrote: > On 8/30/21 2:07 PM, Jason Gunthorpe wrote: > > On Fri, Aug 27, 2021 at 07:34:54PM +0100, Joao Martins wrote: > >> On 8/27/21 5:25 PM, Jason Gunthorpe wrote: > >>> On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: > >>> > >>

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-31 Thread Joao Martins
On 8/30/21 2:07 PM, Jason Gunthorpe wrote: > On Fri, Aug 27, 2021 at 07:34:54PM +0100, Joao Martins wrote: >> On 8/27/21 5:25 PM, Jason Gunthorpe wrote: >>> On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: >>> #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && defined(CONFIG_TRANSP

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-30 Thread Jason Gunthorpe
On Fri, Aug 27, 2021 at 07:34:54PM +0100, Joao Martins wrote: > On 8/27/21 5:25 PM, Jason Gunthorpe wrote: > > On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: > > > >> #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && > >> defined(CONFIG_TRANSPARENT_HUGEPAGE) > >> static int __gup_device

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-27 Thread Joao Martins
On 8/27/21 5:25 PM, Jason Gunthorpe wrote: > On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: > >> #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && >> defined(CONFIG_TRANSPARENT_HUGEPAGE) >> static int __gup_device_huge(unsigned long pfn, unsigned long addr, >>

Re: [PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-27 Thread Jason Gunthorpe
On Fri, Aug 27, 2021 at 03:58:13PM +0100, Joao Martins wrote: > #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && > defined(CONFIG_TRANSPARENT_HUGEPAGE) > static int __gup_device_huge(unsigned long pfn, unsigned long addr, >unsigned long end, unsigned int flags, >

[PATCH v4 08/14] mm/gup: grab head page refcount once for group of subpages

2021-08-27 Thread Joao Martins
Use try_grab_compound_head() for device-dax GUP when configured with a compound devmap. Rather than incrementing the refcount for each page, do one atomic addition for all the pages to be pinned. Performance measured by gup_benchmark improves considerably get_user_pages_fast() and pin_user_pages_