Re: [PATCH v2] mm/swapfile: unuse_pte can map random data if swap read fails

Alistair Popple
2022-04-20T00:38:30Z

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

Miaohe Lin <linmiaohe@huawei.com> writes:

> On 2022/4/19 15:53, Alistair Popple wrote:
>> Also in madvise_free_pte_range() you could just remove the swap entry as it's no
>> longer needed.
>>
>
> This swap entry will be removed in madvise_dontneed_single_vma().
> And in madvise_free_pte_range(), we may need to keep it as same as
> hwpoison entry. Or am I supposed to remove it even if hwpoison entry
> is reused later?

Why would we need to keep it for MADV_FREE though? It only works on private
anonymous memory, and once the MADV_FREE operation has succeeded callers can
expect they might get zero-fill pages if accessing the memory again. Therefore
it should be safe to delete the entry. I think that applies equally to a
hwpoison entry too - there's no reason to kill the process if it has called
MADV_FREE on the range.

>
> Thanks!
>
>> Alistair Popple <apopple@nvidia.com> writes:
>>
>>> Miaohe Lin <linmiaohe@huawei.com> writes:
>>>
> ...