mm/hwpoison: introduce folio_contain_hwpoisoned_page() helper
commit 5f5ee52d4f58605330b09851273d6e56aaadd29e upstream. Patch series "mm/vmscan: don't try to reclaim hwpoison folio". Fix a bug during memory reclaim if folio is hwpoisoned. This patch (of 2): Introduce helper folio_contain_hwpoisoned_page() to check if the entire folio is hwpoisoned or it contains hwpoisoned pages. Link: https://lkml.kernel.org/r/20250318083939.987651-1-tujinjiang@huawei.com Link: https://lkml.kernel.org/r/20250318083939.987651-2-tujinjiang@huawei.com Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com> Acked-by: Miaohe Lin <linmiaohe@huawei.com> Cc: David Hildenbrand <david@redhat.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Nanyong Sun <sunnanyong@huawei.com> Cc: Naoya Horiguchi <nao.horiguchi@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1fd89407d7
commit
65b259e3e0
@@ -1111,6 +1111,12 @@ static inline bool is_page_hwpoison(const struct page *page)
|
|||||||
return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
|
return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool folio_contain_hwpoisoned_page(struct folio *folio)
|
||||||
|
{
|
||||||
|
return folio_test_hwpoison(folio) ||
|
||||||
|
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio));
|
||||||
|
}
|
||||||
|
|
||||||
bool is_free_buddy_page(const struct page *page);
|
bool is_free_buddy_page(const struct page *page);
|
||||||
|
|
||||||
PAGEFLAG(Isolated, isolated, PF_ANY);
|
PAGEFLAG(Isolated, isolated, PF_ANY);
|
||||||
|
|||||||
+1
-2
@@ -1801,8 +1801,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
|
|||||||
if (unlikely(page_folio(page) != folio))
|
if (unlikely(page_folio(page) != folio))
|
||||||
goto put_folio;
|
goto put_folio;
|
||||||
|
|
||||||
if (folio_test_hwpoison(folio) ||
|
if (folio_contain_hwpoisoned_page(folio)) {
|
||||||
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) {
|
|
||||||
if (WARN_ON(folio_test_lru(folio)))
|
if (WARN_ON(folio_test_lru(folio)))
|
||||||
folio_isolate_lru(folio);
|
folio_isolate_lru(folio);
|
||||||
if (folio_mapped(folio)) {
|
if (folio_mapped(folio)) {
|
||||||
|
|||||||
+1
-2
@@ -3042,8 +3042,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (folio_test_hwpoison(folio) ||
|
if (folio_contain_hwpoisoned_page(folio)) {
|
||||||
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) {
|
|
||||||
folio_unlock(folio);
|
folio_unlock(folio);
|
||||||
folio_put(folio);
|
folio_put(folio);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|||||||
Reference in New Issue
Block a user