Skip to contentSkip to conversation

mm/hmm: hmm_range_fault handle pages swapped out

PATCH Applied Yang, Philip 3 participants 5 messages Aug 15, 2019 – Aug 23, 2019

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

PATCH 1/1 mm/hmm: hmm_range_fault handle pages swapped out

hmm_range_fault may return NULL pages because some of pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is for swapped out page pte path, hmm_vma_handle_pte doesn't update fault variable from cpu_flags, so it failed to call hmm_vam_do_fault to swap the page in.

The fix is to call hmm_pte_need_fault to update fault variable.

Change-Id I2e8611485563d11d938881c18b7935fa1e7c91ee
---
 mm/hmm.c | 3 +++
 1 file changed, 3 insertions(+)
mm/hmm.c +3 -0
index 9f22562e2c43..7ca4fb39d3d8 100644
@@ -544,6 +544,9 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
 		swp_entry_t entry = pte_to_swp_entry(pte);
 
 		if (!non_swap_entry(entry)) {
+			cpu_flags = pte_to_hmm_pfn_flags(range, pte);
+			hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags,
+					   &fault, &write_fault);
 			if (fault || write_fault)
 				goto fault;
 			return 0;
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Philip

hmm_range_fault may return NULL pages because some of pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is for swapped out page pte path, hmm_vma_handle_pte doesn't update fault variable from cpu_flags, so it failed to call hmm_vam_do_fault to swap the page in.

The fix is to call hmm_pte_need_fault to update fault variable.

Change-Id I2e8611485563d11d938881c18b7935fa1e7c91ee
Quoted 21 lines
---
 mm/hmm.c | 3 +++
 1 file changed, 3 insertions(+)
mm/hmm.c +3 -0
index 9f22562e2c43..7ca4fb39d3d8 100644
@@ -544,6 +544,9 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
 		swp_entry_t entry = pte_to_swp_entry(pte);
 
 		if (!non_swap_entry(entry)) {
+			cpu_flags = pte_to_hmm_pfn_flags(range, pte);
+			hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags,
+					   &fault, &write_fault);
 			if (fault || write_fault)
 				goto fault;
 			return 0;
Signature · 1 line
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Yang, Philip
Quoted 9 lines · Philip

hmm_range_fault may return NULL pages because some of pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is for swapped out page pte path, hmm_vma_handle_pte doesn't update fault variable from cpu_flags, so it failed to call hmm_vam_do_fault to swap the page in.

The fix is to call hmm_pte_need_fault to update fault variable.

Change-Id: I2e8611485563d11d938881c18b7935fa1e7c91ee

I'll fix it for you but please be careful not to send Change-id's to the public lists.

Also what is the Fixes line for this?

Quoted 3 lines
 mm/hmm.c | 3 +++
 1 file changed, 3 insertions(+)

Ralph has also been looking at this area also so I'll give him a bit to chime in, otherwise with Jerome's review this looks OK to go to linux-next

Thanks,
Jason
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Philip

hmm_range_fault may return NULL pages because some of pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is for swapped out page pte path, hmm_vma_handle_pte doesn't update fault variable from cpu_flags, so it failed to call hmm_vam_do_fault to swap the page in.

Quoted 7 lines
Quoted 3 lines

The fix is to call hmm_pte_need_fault to update fault variable.

Change-Id: I2e8611485563d11d938881c18b7935fa1e7c91ee

I'll fix it for you but please be careful not to send Change-id's to the public lists.

Thanks, the change-id was added by our Gerrit hook, I need generate patch files, remove change-id line and then send out modified patch files in future.

Quoted 2 lines

Also what is the Fixes line for this?

This fixes the issue found by the internal rocrtst, the rocrtstFunc.Memory_Max_Mem evicted some user buffers, and then following test restore those user buffers failed because the buffers are swapped out and application doesn't touch the buffers to swap it in.

Quoted 8 lines
Quoted 3 lines
  mm/hmm.c | 3 +++
  1 file changed, 3 insertions(+)

Ralph has also been looking at this area also so I'll give him a bit to chime in, otherwise with Jerome's review this looks OK to go to linux-next

Ok, thanks for helping push this to hmm branch at
https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git

Quoted 3 lines

Thanks,
Jason

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by Jérôme Glisse on v1 1/1 Applied
#4 lore raw
In reply to Yang, Philip
Quoted 6 lines · Philip

hmm_range_fault may return NULL pages because some of pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is for swapped out page pte path, hmm_vma_handle_pte doesn't update fault variable from cpu_flags, so it failed to call hmm_vam_do_fault to swap the page in.

Quoted 6 lines

The fix is to call hmm_pte_need_fault to update fault variable.

Change-Id I2e8611485563d11d938881c18b7935fa1e7c91ee
 mm/hmm.c | 3 +++
 1 file changed, 3 insertions(+)

Applied to hmm.git, thanks

I fixed the commit message:

Author: Yang, Philip <[email protected]>
Date:   Thu Aug 15 20:52:56 2019 +0000

mm/hmm: fix hmm_range_fault()'s handling of swapped out pages

hmm_range_fault() may return NULL pages because some of the pfns are equal to HMM_PFN_NONE. This happens randomly under memory pressure. The reason is during the swapped out page pte path, hmm_vma_handle_pte() doesn't update the fault variable from cpu_flags, so it failed to call hmm_vam_do_fault() to swap the page in.

The fix is to call hmm_pte_need_fault() to update fault variable.

Fixes 74eee180b935 ("mm/hmm/mirror: device page fault handler")

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx