Message ID | 20220424091105.48374-4-linmiaohe@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | A few fixup patches for mm | expand |
On Sun, Apr 24, 2022 at 05:11:05PM +0800, Miaohe Lin wrote: > 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 hwpoison entry and swapin error entry. There is no > reason to kill the process if it has called MADV_FREE on the range. > > Suggested-by: Alistair Popple <apopple@nvidia.com> > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > Acked-by: David Hildenbrand <david@redhat.com> I confirmed that hwpoison entry is properly removed with madvise(MADV_FREE) with this patch. This provides applications with the ability to recover from memory errors in simpler way (applications don't have to munmap then mmap again the error address). That's a good small improvement. Thank you. Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com> > --- > mm/madvise.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/mm/madvise.c b/mm/madvise.c > index 4d6592488b51..5f4537511532 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -624,11 +624,14 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, > swp_entry_t entry; > > entry = pte_to_swp_entry(ptent); > - if (non_swap_entry(entry)) > - continue; > - nr_swap--; > - free_swap_and_cache(entry); > - pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > + if (!non_swap_entry(entry)) { > + nr_swap--; > + free_swap_and_cache(entry); > + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > + } else if (is_hwpoison_entry(entry) || > + is_swapin_error_entry(entry)) { > + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > + } > continue; > } > > -- > 2.23.0
On 2022/4/25 7:41, HORIGUCHI NAOYA(堀口 直也) wrote: > On Sun, Apr 24, 2022 at 05:11:05PM +0800, Miaohe Lin wrote: >> 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 hwpoison entry and swapin error entry. There is no >> reason to kill the process if it has called MADV_FREE on the range. >> >> Suggested-by: Alistair Popple <apopple@nvidia.com> >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> >> Acked-by: David Hildenbrand <david@redhat.com> > > I confirmed that hwpoison entry is properly removed with madvise(MADV_FREE) > with this patch. This provides applications with the ability to recover from > memory errors in simpler way (applications don't have to munmap then mmap again > the error address). That's a good small improvement. Thank you. > > Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Many thanks for your testing and review! :) > >> --- >> mm/madvise.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/mm/madvise.c b/mm/madvise.c >> index 4d6592488b51..5f4537511532 100644 >> --- a/mm/madvise.c >> +++ b/mm/madvise.c >> @@ -624,11 +624,14 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, >> swp_entry_t entry; >> >> entry = pte_to_swp_entry(ptent); >> - if (non_swap_entry(entry)) >> - continue; >> - nr_swap--; >> - free_swap_and_cache(entry); >> - pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + if (!non_swap_entry(entry)) { >> + nr_swap--; >> + free_swap_and_cache(entry); >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + } else if (is_hwpoison_entry(entry) || >> + is_swapin_error_entry(entry)) { >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); >> + } >> continue; >> } >> >> -- >> 2.23.0
diff --git a/mm/madvise.c b/mm/madvise.c index 4d6592488b51..5f4537511532 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -624,11 +624,14 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, swp_entry_t entry; entry = pte_to_swp_entry(ptent); - if (non_swap_entry(entry)) - continue; - nr_swap--; - free_swap_and_cache(entry); - pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); + if (!non_swap_entry(entry)) { + nr_swap--; + free_swap_and_cache(entry); + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); + } else if (is_hwpoison_entry(entry) || + is_swapin_error_entry(entry)) { + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); + } continue; }