diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9d87fcab96c9..73066b80d14a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -916,6 +916,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, bool unmap_success; int kill = 1, forcekill; struct page *hpage = *hpagep; + bool mlocked = PageMlocked(hpage); /* * Here we are interested only in user-mapped pages, so skip any @@ -979,6 +980,13 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n", pfn, page_mapcount(hpage)); + /* + * try_to_unmap() might put mlocked page in lru cache, so call + * shake_page() again to ensure that it's flushed. + */ + if (mlocked) + shake_page(hpage, 0); + /* * Now that the dirty bit has been propagated to the * struct page and all unmaps done we can decide if