[PATCH] mm/hmm: remove hmm_range vma
From: Jason Gunthorpe
Date: Tue Jul 23 2019 - 11:28:32 EST
This value is only read inside hmm_vma_walk_pmd() and all the callers,
through walk_page_range(), always set the value. The proper place for
per-walk data is in hmm_vma_walk, and since the only usage is a vm_flags
test just precompute and store that.
Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
drivers/gpu/drm/nouveau/nouveau_svm.c | 7 +++----
include/linux/hmm.h | 1 -
mm/hmm.c | 11 ++++++-----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouvea=
u/nouveau_svm.c
index a9c5c58d425b3d..4f4bec40b887a6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -495,12 +495,12 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct=
hmm_range *range)
range->start, range->end,
PAGE_SHIFT);
if (ret) {
- up_read(&range->vma->vm_mm->mmap_sem);
+ up_read(&range->hmm->mm->mmap_sem);
return (int)ret;
}
=20
if (!hmm_range_wait_until_valid(range, HMM_RANGE_DEFAULT_TIMEOUT)) {
- up_read(&range->vma->vm_mm->mmap_sem);
+ up_read(&range->hmm->mm->mmap_sem);
return -EBUSY;
}
=20
@@ -508,7 +508,7 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct h=
mm_range *range)
if (ret <=3D 0) {
if (ret =3D=3D 0)
ret =3D -EBUSY;
- up_read(&range->vma->vm_mm->mmap_sem);
+ up_read(&range->hmm->mm->mmap_sem);
hmm_range_unregister(range);
return ret;
}
@@ -681,7 +681,6 @@ nouveau_svm_fault(struct nvif_notify *notify)
args.i.p.addr + args.i.p.size, fn - fi);
=20
/* Have HMM fault pages within the fault window to the GPU. */
- range.vma =3D vma;
range.start =3D args.i.p.addr;
range.end =3D args.i.p.addr + args.i.p.size;
range.pfns =3D args.phys;
diff --git a/include/linux/hmm.h b/include/linux/hmm.h
index 9f32586684c9c3..d4b89f655817cd 100644
--- a/include/linux/hmm.h
+++ b/include/linux/hmm.h
@@ -164,7 +164,6 @@ enum hmm_pfn_value_e {
*/
struct hmm_range {
struct hmm *hmm;
- struct vm_area_struct *vma;
struct list_head list;
unsigned long start;
unsigned long end;
diff --git a/mm/hmm.c b/mm/hmm.c
index 16b6731a34db79..3d8cdfb67a6ab8 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -285,8 +285,9 @@ struct hmm_vma_walk {
struct hmm_range *range;
struct dev_pagemap *pgmap;
unsigned long last;
- bool fault;
- bool block;
+ bool fault : 1;
+ bool block : 1;
+ bool hugetlb : 1;
};
=20
static int hmm_vma_do_fault(struct mm_walk *walk, unsigned long addr,
@@ -635,7 +636,7 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
if (pmd_none(pmd))
return hmm_vma_walk_hole(start, end, walk);
=20
- if (pmd_huge(pmd) && (range->vma->vm_flags & VM_HUGETLB))
+ if (pmd_huge(pmd) && hmm_vma_walk->hugetlb)
return hmm_pfns_bad(start, end, walk);
=20
if (thp_migration_supported() && is_pmd_migration_entry(pmd)) {
@@ -994,7 +995,7 @@ long hmm_range_snapshot(struct hmm_range *range)
return -EPERM;
}
=20
- range->vma =3D vma;
+ hmm_vma_walk.hugetlb =3D vma->vm_flags & VM_HUGETLB;
hmm_vma_walk.pgmap =3D NULL;
hmm_vma_walk.last =3D start;
hmm_vma_walk.fault =3D false;
@@ -1090,7 +1091,7 @@ long hmm_range_fault(struct hmm_range *range, bool bl=
ock)
return -EPERM;
}
=20
- range->vma =3D vma;
+ hmm_vma_walk.hugetlb =3D vma->vm_flags & VM_HUGETLB;
hmm_vma_walk.pgmap =3D NULL;
hmm_vma_walk.last =3D start;
hmm_vma_walk.fault =3D true;
--=20
2.22.0