Skip to contentSkip to conversation

mm/memory: Return vm_fault_t result from migrate_to_ram() callback

PATCH Applied Alistair Popple 3 participants 3 messages Nov 14, 2022

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

PATCH 1/1 mm/memory: Return vm_fault_t result from migrate_to_ram() callback

The migrate_to_ram() callback should always succeed, but in rare cases can fail usually returning VM_FAULT_SIGBUS. Commit 16ce101db85d ("mm/memory.c: fix race when faulting a device private page") incorrectly stopped passing the return code up the stack. Fix this by setting the ret variable, restoring the previous behaviour on migrate_to_ram() failure.

Fixes 16ce101db85d ("mm/memory.c: fix race when faulting a device private page")
Cc Ralph Campbell <[email protected]>
Cc John Hubbard <[email protected]>
Cc Alex Sierra <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Michael Ellerman <[email protected]>

---

Hi Andrew, I noticed my series needs another small fix which I'm hoping you can apply for v6.1-rcX. Thanks (and sorry for not catching this sooner).

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
index f88c351aecd4..8a6d5c823f91 100644
@@ -3763,7 +3763,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
 			 */
 			get_page(vmf->page);
 			pte_unmap_unlock(vmf->pte, vmf->ptl);
-			vmf->page->pgmap->ops->migrate_to_ram(vmf);
+			ret = vmf->page->pgmap->ops->migrate_to_ram(vmf);
 			put_page(vmf->page);
 		} else if (is_hwpoison_entry(entry)) {
 			ret = VM_FAULT_HWPOISON;
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Alistair Popple

The migrate_to_ram() callback should always succeed, but in rare cases can fail usually returning VM_FAULT_SIGBUS. Commit 16ce101db85d ("mm/memory.c: fix race when faulting a device private page") incorrectly stopped passing the return code up the stack. Fix this by setting the ret variable, restoring the previous behaviour on migrate_to_ram() failure.

Fixes 16ce101db85d ("mm/memory.c: fix race when faulting a device private page")
Cc Ralph Campbell <[email protected]>
Cc John Hubbard <[email protected]>
Cc Alex Sierra <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Michael Ellerman <[email protected]>

---

Hi Andrew, I noticed my series needs another small fix which I'm hoping you can apply for v6.1-rcX. Thanks (and sorry for not catching this sooner).

---
  mm/memory.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index f88c351aecd4..8a6d5c823f91 100644

mm/memory.c vm_fault_t do_swap_page(struct vm_fault *vmf) · line 3769

Quoted 8 lines
mm/memory.c +1 -1
@@ -3763,7 +3763,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
  			 */
  			get_page(vmf->page);
  			pte_unmap_unlock(vmf->pte, vmf->ptl);
-			vmf->page->pgmap->ops->migrate_to_ram(vmf);
+			ret = vmf->page->pgmap->ops->migrate_to_ram(vmf);
  			put_page(vmf->page);
  		} else if (is_hwpoison_entry(entry)) {
  			ret = VM_FAULT_HWPOISON;
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by
#2 lore raw

Am 2022-11-14 um 11:41 schrieb David Hildenbrand:

Quoted 8 lines · Alistair Popple
Quoted 7 lines

The migrate_to_ram() callback should always succeed, but in rare cases can fail usually returning VM_FAULT_SIGBUS. Commit 16ce101db85d ("mm/memory.c: fix race when faulting a device private page") incorrectly stopped passing the return code up the stack. Fix this by setting the ret variable, restoring the previous behaviour on migrate_to_ram() failure.

Quoted 10 lines
Quoted 10 lines
Fixes 16ce101db85d ("mm/memory.c: fix race when faulting a device private page")
Cc Ralph Campbell <[email protected]>
Cc John Hubbard <[email protected]>
Cc Alex Sierra <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Michael Ellerman <[email protected]>
Quoted 27 lines
Quoted 15 lines

---

Hi Andrew, I noticed my series needs another small fix which I'm hoping you can apply for v6.1-rcX. Thanks (and sorry for not catching this sooner).
---
  mm/memory.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index f88c351aecd4..8a6d5c823f91 100644

mm/memory.c vm_fault_t do_swap_page(struct vm_fault *vmf) · line 3769

Quoted 8 lines
mm/memory.c +1 -1
@@ -3763,7 +3763,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
                */
               get_page(vmf->page);
               pte_unmap_unlock(vmf->pte, vmf->ptl);
- vmf->page->pgmap->ops->migrate_to_ram(vmf);
+            ret = vmf->page->pgmap->ops->migrate_to_ram(vmf);
               put_page(vmf->page);
           } else if (is_hwpoison_entry(entry)) {
               ret = VM_FAULT_HWPOISON;