diff mbox series

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

Message ID 20221114115537.727371-1-apopple@nvidia.com (mailing list archive)
State New
Headers show
Series mm/memory: Return vm_fault_t result from migrate_to_ram() callback | expand

Commit Message

Alistair Popple Nov. 14, 2022, 11:55 a.m. UTC
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")
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Alex Sierra <alex.sierra@amd.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>

---

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(-)

Comments

David Hildenbrand Nov. 14, 2022, 4:41 p.m. UTC | #1
On 14.11.22 12:55, Alistair Popple wrote:
> 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")
> Signed-off-by: Alistair Popple <apopple@nvidia.com>
> Cc: Ralph Campbell <rcampbell@nvidia.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Alex Sierra <alex.sierra@amd.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> 
> ---
> 
> 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(-)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index f88c351aecd4..8a6d5c823f91 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -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;


Acked-by: David Hildenbrand <david@redhat.com>
Felix Kuehling Nov. 14, 2022, 5:26 p.m. UTC | #2
Am 2022-11-14 um 11:41 schrieb David Hildenbrand:
> On 14.11.22 12:55, Alistair Popple wrote:
>> 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")
>> Signed-off-by: Alistair Popple <apopple@nvidia.com>
>> Cc: Ralph Campbell <rcampbell@nvidia.com>
>> Cc: John Hubbard <jhubbard@nvidia.com>
>> Cc: Alex Sierra <alex.sierra@amd.com>
>> Cc: Ben Skeggs <bskeggs@redhat.com>
>> Cc: Felix Kuehling <Felix.Kuehling@amd.com>
>> Cc: Lyude Paul <lyude@redhat.com>
>> Cc: Jason Gunthorpe <jgg@nvidia.com>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>


>>
>> ---
>>
>> 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(-)
>>
>> diff --git a/mm/memory.c b/mm/memory.c
>> index f88c351aecd4..8a6d5c823f91 100644
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -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;
>
>
> Acked-by: David Hildenbrand <david@redhat.com>
>
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index f88c351aecd4..8a6d5c823f91 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -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;