[Nouveau] [PATCH 0/2] mm/hmm: two bug fixes for hmm_range_fault()

2019-08-23 Thread Ralph Campbell
thought they shouldn't wait. They should probably have a fixes line but with all the HMM changes, I wasn't sure exactly which commit to use. These are based on top of Jason's latest hmm branch. Ralph Campbell (2): mm/hmm: hmm_range_fault() NULL pointer bug mm/hmm: hmm_range_fault() infinite loop

[Nouveau] [PATCH 1/2] mm/hmm: hmm_range_fault() NULL pointer bug

2019-08-23 Thread Ralph Campbell
nge check */ walk_page_range() /* calls find_vma(), sets walk->vma = NULL */ __walk_page_range() walk_pgd_range() walk_p4d_range() walk_pud_range() hmm_vma_walk_hole() hmm_vma_walk_hole_() hmm_vma_do_fault() handle_mm_fault(vma=0) Signed-off-by:

[PATCH 2/2] mm/hmm: hmm_range_fault() infinite loop

2019-08-23 Thread Ralph Campbell
rns -EBUSY */ /* returns -EBUSY */ /* loops on -EBUSY and range->valid */ Prevent this by checking for vma->vm_flags & VM_WRITE before calling handle_mm_fault(). Signed-off-by: Ralph Campbell --- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/hmm.c b/m

Re: [PATCH 04/15] mm: remove the pgmap field from struct hmm_vma_walk

2019-08-16 Thread Ralph Campbell
On 8/16/19 10:28 AM, Jason Gunthorpe wrote: On Fri, Aug 16, 2019 at 10:21:41AM -0700, Dan Williams wrote: We can do a get_dev_pagemap inside the page_walk and touch the pgmap, or we can do the 'device mutex && retry' pattern and touch the pgmap in the driver, under that lock. However in all

Re: turn hmm migrate_vma upside down v3

2019-08-14 Thread Ralph Campbell
mmu_notifier branch. So for the series you can add: Tested-by: Ralph Campbell

Re: [PATCH] nouveau/hmm: map pages after migration

2019-08-12 Thread Ralph Campbell
On 8/10/19 4:13 AM, Christoph Hellwig wrote: On something vaguely related to this patch: You use the NVIF_VMM_PFNMAP_V0_V* defines from nvif/if000c.h, which are a little odd as we only ever set these bits, but they also don't seem to appear to be in values that are directly fed to the

Re: [PATCH] nouveau/hmm: map pages after migration

2019-08-08 Thread Ralph Campbell
On 8/8/19 12:07 AM, Christoph Hellwig wrote: On Wed, Aug 07, 2019 at 08:02:14AM -0700, Ralph Campbell wrote: When memory is migrated to the GPU it is likely to be accessed by GPU code soon afterwards. Instead of waiting for a GPU fault, map the migrated memory into the GPU page tables

Re: [PATCH 6/9] nouveau: simplify nouveau_dmem_migrate_to_ram

2019-08-08 Thread Ralph Campbell
Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 159 +++-- 1 file changed, 40 insertions(+), 119 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 21052a4aaf69..473195762974

[Nouveau] [PATCH] nouveau/hmm: map pages after migration

2019-08-07 Thread Ralph Campbell
-off-by: Ralph Campbell Cc: Christoph Hellwig Cc: Jason Gunthorpe Cc: "Jérôme Glisse" Cc: Ben Skeggs --- This patch is based on top of Christoph Hellwig's 9 patch series https://lore.kernel.org/linux-mm/20190729234611.gc7...@redhat.com/T/#u "turn the hmm migrate_vma upside down&quo

Re: [PATCH 1/9] mm: turn migrate_vma upside down

2019-07-30 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: There isn't any good reason to pass callbacks to migrate_vma. Instead we can just export the three steps done by this function to drivers and let them sequence the operation without callbacks. This removes a lot of boilerplate code as-is, and will

Re: [Nouveau] [PATCH 08/13] mm: remove the mask variable in hmm_vma_walk_hugetlb_entry

2019-07-30 Thread Ralph Campbell
On 7/29/19 10:51 PM, Christoph Hellwig wrote: The pagewalk code already passes the value as the hmask parameter. Signed-off-by: Christoph Hellwig --- mm/hmm.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index f26d6abc4ed2..88b77a4a6a1e

Re: [Nouveau] [PATCH 9/9] mm: remove the MIGRATE_PFN_WRITE flag

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: The MIGRATE_PFN_WRITE is only used locally in migrate_vma_collect_pmd, where it can be replaced with a simple boolean local variable. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- include/linux/migrate.h | 1 - mm

Re: [PATCH 8/9] mm: remove the unused MIGRATE_PFN_DEVICE flag

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: No one ever checks this flag, and we could easily get that information from the page if needed. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 3 +-- include/linux/migrate.h

Re: [Nouveau] [PATCH 6/9] nouveau: simplify nouveau_dmem_migrate_vma

2019-07-29 Thread Ralph Campbell
and reuses it for each subsequent chunk of work. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 185 - 1 file changed, 56 insertions(+), 129 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c

Re: [PATCH 7/9] mm: remove the unused MIGRATE_PFN_ERROR flag

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: We don't use this flag anymore, so remove it. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- include/linux/migrate.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h

Re: [PATCH 5/9] nouveau: simplify nouveau_dmem_migrate_to_ram

2019-07-29 Thread Ralph Campbell
Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 158 ++--- 1 file changed, 39 insertions(+), 119 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 21052a4aaf69..036e6c07d489

Re: [Nouveau] [PATCH 4/9] nouveau: factor out dmem fence completion

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: Factor out the end of fencing logic from the two migration routines. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 33 -- 1 file changed, 15 insertions

Re: [Nouveau] [PATCH 3/9] nouveau: factor out device memory address calculation

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: Factor out the repeated device memory address calculation into a helper. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 42 +++--- 1 file changed, 17 insertions

Re: [PATCH 2/9] nouveau: reset dma_nr in nouveau_dmem_migrate_alloc_and_copy

2019-07-29 Thread Ralph Campbell
On 7/29/19 7:28 AM, Christoph Hellwig wrote: When we start a new batch of dma_map operations we need to reset dma_nr, as we start filling a newly allocated array. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 1 + 1 file

Re: [PATCH 1/9] mm: turn migrate_vma upside down

2019-07-29 Thread Ralph Campbell
as-is, and will allow the drivers to drastically improve code flow and error handling further on. Signed-off-by: Christoph Hellwig Except for a few white space errors ( and $), looks OK. Reviewed-by: Ralph Campbell --- Documentation/vm/hmm.rst | 55 +- drivers/gpu/drm/nouveau

Re: [PATCH v2 2/7] mm/hmm: a few more C style and comment clean ups

2019-07-26 Thread Ralph Campbell
On 7/25/19 11:23 PM, Christoph Hellwig wrote: Note: it seems like you've only CCed me on patches 2-7, but not on the cover letter and patch 1. I'll try to find them later, but to make Ccs useful they should normally cover the whole series. Otherwise this looks fine to me: Reviewed-by:

[Nouveau] [PATCH v2 6/7] mm/hmm: remove hugetlbfs check in hmm_vma_walk_pmd

2019-07-25 Thread Ralph Campbell
walk_page_range() will only call hmm_vma_walk_hugetlb_entry() for hugetlbfs pages and doesn't call hmm_vma_walk_pmd() in this case. Therefore, it is safe to remove the check for vma->vm_flags & VM_HUGETLB in hmm_vma_walk_pmd(). Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse

[Nouveau] [PATCH v2 7/7] mm/hmm: remove hmm_range vma

2019-07-25 Thread Ralph Campbell
Since hmm_range_fault() doesn't use the struct hmm_range vma field, remove it. Suggested-by: Jason Gunthorpe Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_svm.c | 7 +++ include/linux/hmm.h | 1

[PATCH v2 2/7] mm/hmm: a few more C style and comment clean ups

2019-07-25 Thread Ralph Campbell
A few more comments and minor programming style clean ups. There should be no functional changes. Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: Jason Gunthorpe Cc: Christoph Hellwig --- mm/hmm.c | 39 +-- 1 file changed, 17 inserti

[Nouveau] [PATCH v2 5/7] mm/hmm: make full use of walk_page_range()

2019-07-25 Thread Ralph Campbell
hmm_range_fault() calls find_vma() and walk_page_range() in a loop. This is unnecessary duplication since walk_page_range() calls find_vma() in a loop already. Simplify hmm_range_fault() by defining a walk_test() callback function to filter unhandled vmas. Signed-off-by: Ralph Campbell Cc

[Nouveau] [PATCH v2 4/7] mm: merge hmm_range_snapshot into hmm_range_fault

2019-07-25 Thread Ralph Campbell
From: Christoph Hellwig Add a HMM_FAULT_SNAPSHOT flag so that hmm_range_snapshot can be merged into the almost identical hmm_range_fault function. Signed-off-by: Christoph Hellwig Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: Jason Gunthorpe --- Documentation/vm/hm

[PATCH v2 3/7] mm/hmm: replace the block argument to hmm_range_fault with a flags value

2019-07-25 Thread Ralph Campbell
From: Christoph Hellwig This allows easier expansion to other flags, and also makes the callers a little easier to read. Signed-off-by: Christoph Hellwig Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse" Cc: Jason Gunthorpe --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- d

[Nouveau] [PATCH v2 0/7] mm/hmm: more HMM clean up

2019-07-25 Thread Ralph Campbell
m v1 to v2: Added AMD GPU to hmm_update removal. Added 2 patches from Christoph. Added 2 patches as a result of Jason's suggestions. Christoph Hellwig (2): mm/hmm: replace the block argument to hmm_range_fault with a flags value mm: merge hmm_range_snapshot into hmm_range_fault Ralph Campbell

[Nouveau] [PATCH v2 1/7] mm/hmm: replace hmm_update with mmu_notifier_range

2019-07-25 Thread Ralph Campbell
The hmm_mirror_ops callback function sync_cpu_device_pagetables() passes a struct hmm_update which is a simplified version of struct mmu_notifier_range. This is unnecessary so replace hmm_update with mmu_notifier_range directly. Signed-off-by: Ralph Campbell Reviewed: Christoph Hellwig Cc

Re: [Nouveau] hmm_range_fault related fixes and legacy API removal v3

2019-07-25 Thread Ralph Campbell
On 7/25/19 5:16 PM, Jason Gunthorpe wrote: On Wed, Jul 24, 2019 at 08:52:51AM +0200, Christoph Hellwig wrote: Hi Jérôme, Ben and Jason, below is a series against the hmm tree which fixes up the mmap_sem locking in nouveau and while at it also removes leftover legacy HMM APIs only used by

Re: [Nouveau] [PATCH] mm/hmm: replace hmm_update with mmu_notifier_range

2019-07-25 Thread Ralph Campbell
On 7/24/19 6:14 PM, Jason Gunthorpe wrote: On Tue, Jul 23, 2019 at 02:05:06PM -0700, Ralph Campbell wrote: The hmm_mirror_ops callback function sync_cpu_device_pagetables() passes a struct hmm_update which is a simplified version of struct mmu_notifier_range. This is unnecessary so replace

[PATCH] mm/hmm: replace hmm_update with mmu_notifier_range

2019-07-23 Thread Ralph Campbell
The hmm_mirror_ops callback function sync_cpu_device_pagetables() passes a struct hmm_update which is a simplified version of struct mmu_notifier_range. This is unnecessary so replace hmm_update with mmu_notifier_range directly. Signed-off-by: Ralph Campbell Cc: "Jérôme Glisse"

Re: [Nouveau] hmm_range_fault related fixes and legacy API removal v2

2019-07-22 Thread Ralph Campbell
, 5.3.0-rc1, and my two HMM fixes: ("mm/hmm: fix ZONE_DEVICE anon page mapping reuse") ("mm/hmm: Fix bad subpage pointer in try_to_unmap_one") You can add for the series: Tested-by: Ralph Campbell ___ Nouveau mailing list Nouveau@lists.f

Re: [Nouveau] hmm_range_fault related fixes and legacy API removal v2

2019-07-08 Thread Ralph Campbell
On 7/4/19 9:42 AM, Jason Gunthorpe wrote: On Wed, Jul 03, 2019 at 03:02:08PM -0700, Christoph Hellwig wrote: Hi Jérôme, Ben and Jason, below is a series against the hmm tree which fixes up the mmap_sem locking in nouveau and while at it also removes leftover legacy HMM APIs only used by

Re: [Nouveau] [PATCH 4/5] nouveau: unlock mmap_sem on all errors from nouveau_range_fault

2019-07-03 Thread Ralph Campbell
unlocking it in the caller for successful returns. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_svm.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu

Re: [PATCH 5/5] mm: remove the legacy hmm_pfn_* APIs

2019-07-03 Thread Ralph Campbell
On 7/3/19 11:45 AM, Christoph Hellwig wrote: Switch the one remaining user in nouveau over to its replacement, and remove all the wrappers. Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2

Re: [PATCH 20/22] mm: move hmm_vma_fault to nouveau

2019-07-03 Thread Ralph Campbell
/ fixing a locking bug involving caller and callee. Signed-off-by: Christoph Hellwig I see where you are going with this and it looks like straightforward code movement so, Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_svm.c | 54 ++- include/l

Re: [PATCH 19/22] mm: always return EBUSY for invalid ranges in hmm_range_{fault,snapshot}

2019-07-03 Thread Ralph Campbell
-by: Christoph Hellwig Reviewed-by: Ralph Campbell Probably should update the "Return:" comment above hmm_range_snapshot() too. --- mm/hmm.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index c85ed7d4e2ce..d125df698e2b 100644 ---

Re: [PATCH 18/22] mm: return valid info from hmm_range_unregister

2019-07-03 Thread Ralph Campbell
oph Hellwig Reviewed-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- include/linux/hmm.h | 11 +-- mm/hmm.c | 6 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouv

[PATCH v2] drm/nouveau/dmem: missing mutex_lock in error path

2019-06-14 Thread Ralph Campbell
0246 R12: 40406449 [ 1295.208083] R13: 0004 R14: R15: Reacquire the lock before continuing to the next page. Signed-off-by: Ralph Campbell --- I found this while testing Jason Gunthorpe's hmm tree but this is independent of those changes. Ja

Re: [PATCH] drm/nouveau/dmem: missing mutex_lock in error path

2019-06-14 Thread Ralph Campbell
On 6/13/19 5:49 PM, John Hubbard wrote: On 6/13/19 5:11 PM, Ralph Campbell wrote: In nouveau_dmem_pages_alloc(), the drm->dmem->mutex is unlocked before calling nouveau_dmem_chunk_alloc(). Reacquire the lock before continuing to the next page. Signed-off-by: Ralph Campbell --- I

[PATCH] drm/nouveau/dmem: missing mutex_lock in error path

2019-06-13 Thread Ralph Campbell
In nouveau_dmem_pages_alloc(), the drm->dmem->mutex is unlocked before calling nouveau_dmem_chunk_alloc(). Reacquire the lock before continuing to the next page. Signed-off-by: Ralph Campbell --- I found this while testing Jason Gunthorpe's hmm tree but this is independant of those chan

Re: [PATCH 10/22] memremap: add a migrate callback to struct dev_pagemap_ops

2019-06-13 Thread Ralph Campbell
page(entry); + ret = page->pgmap->ops->migrate(vmf); This needs to either initialize "page" or be changed to "vmf->page". Otherwise, it is a NULL pointer dereference. } else if (is_hwpoison_entry(entry)) { ret = VM_FAULT_HWPOISON; } else { You can add: Reviewed-by: Ralph Campbell

Re: [PATCH 18/22] mm: mark DEVICE_PUBLIC as broken

2019-06-13 Thread Ralph Campbell
On 6/13/19 12:44 PM, Jason Gunthorpe wrote: On Thu, Jun 13, 2019 at 11:43:21AM +0200, Christoph Hellwig wrote: The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Mark it as BROKEN until either a user comes along or we finally give up on it.

<    1   2   3