[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220519125030.21486-4-linmiaohe@huawei.com>
Date: Thu, 19 May 2022 20:50:28 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: <akpm@...ux-foundation.org>, <hughd@...gle.com>
CC: <willy@...radead.org>, <vbabka@...e.cz>, <dhowells@...hat.com>,
<neilb@...e.de>, <apopple@...dia.com>, <david@...hat.com>,
<surenb@...gle.com>, <peterx@...hat.com>, <rcampbell@...dia.com>,
<naoya.horiguchi@....com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <linmiaohe@...wei.com>
Subject: [PATCH v4 3/5] mm/madvise: free hwpoison and swapin error entry in madvise_free_pte_range
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@...dia.com>
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
Acked-by: David Hildenbrand <david@...hat.com>
Reviewed-by: Naoya Horiguchi <naoya.horiguchi@....com>
---
mm/madvise.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/mm/madvise.c b/mm/madvise.c
index caa53806addd..a42165bc4735 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
Powered by blists - more mailing lists