Skip to contentSkip to conversation

mm/hmm: Fix initial PFN for hugetlbfs pages

PATCH RESEND In review [email protected] 2 participants 2 messages Apr 19, 2019 – Apr 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 mm/hmm: Fix initial PFN for hugetlbfs pages

From: Ralph Campbell <[email protected]>

The mmotm patch [1] adds hugetlbfs support for HMM but the initial PFN used to fill the HMM range->pfns[] array doesn't properly compute the starting PFN offset.
This can be tested by running test-hugetlbfs-read from [2].

Fix the PFN offset by adjusting the page offset by the device's page size.

Andrew, this should probably be squashed into Jerome's patch.

[1] https://marc.info/?l=linux-mm&m=155432003506068&w=2
("mm/hmm: mirror hugetlbfs (snapshoting, faulting and DMA mapping)")
[2] https://gitlab.freedesktop.org/glisse/svm-cl-tests

Cc Jérôme Glisse <[email protected]>
Cc Ira Weiny <[email protected]>
Cc John Hubbard <[email protected]>
Cc Dan Williams <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Souptick Joarder <[email protected]>
Cc Andrew Morton <[email protected]>
---
 mm/hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hmm.c +1 -1
index def451a56c3e..fcf8e4fb5770 100644
@@ -868,7 +868,7 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
 		goto unlock;
 	}
 
-	pfn = pte_pfn(entry) + (start & mask);
+	pfn = pte_pfn(entry) + ((start & mask) >> range->page_shift);
 	for (; addr < end; addr += size, i++, pfn += pfn_inc)
 		range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) |
 				 cpu_flags;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Fri, Apr 19, 2019 at 04:35:36PM -0700, [email protected] wrote:

From: Ralph Campbell <[email protected]>

The mmotm patch [1] adds hugetlbfs support for HMM but the initial PFN used to fill the HMM range->pfns[] array doesn't properly compute the starting PFN offset.
This can be tested by running test-hugetlbfs-read from [2].

Fix the PFN offset by adjusting the page offset by the device's page size.

Quoted 7 lines

Andrew, this should probably be squashed into Jerome's patch.

[1] https://marc.info/?l=linux-mm&m=155432003506068&w=2
("mm/hmm: mirror hugetlbfs (snapshoting, faulting and DMA mapping)")
[2] https://gitlab.freedesktop.org/glisse/svm-cl-tests

Good catch.

Quoted 30 lines
Cc Jérôme Glisse <[email protected]>
Cc Ira Weiny <[email protected]>
Cc John Hubbard <[email protected]>
Cc Dan Williams <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Souptick Joarder <[email protected]>
Cc Andrew Morton <[email protected]>
---
 mm/hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hmm.c +1 -1
index def451a56c3e..fcf8e4fb5770 100644
@@ -868,7 +868,7 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask,
 		goto unlock;
 	}
 
-	pfn = pte_pfn(entry) + (start & mask);
+	pfn = pte_pfn(entry) + ((start & mask) >> range->page_shift);
 	for (; addr < end; addr += size, i++, pfn += pfn_inc)
 		range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) |
 				 cpu_flags;
Signature · 1 line
2.20.1