WIP: update tizen_qemu_defconfig
[platform/kernel/linux-starfive.git] / mm / memory-failure.c
index 145bb56..4457f94 100644 (file)
@@ -1020,7 +1020,7 @@ static int me_pagecache_dirty(struct page_state *ps, struct page *p)
  * cache and swap cache(ie. page is freshly swapped in). So it could be
  * referenced concurrently by 2 types of PTEs:
  * normal PTEs and swap PTEs. We try to handle them consistently by calling
- * try_to_unmap(TTU_IGNORE_HWPOISON) to convert the normal PTEs to swap PTEs,
+ * try_to_unmap(!TTU_HWPOISON) to convert the normal PTEs to swap PTEs,
  * and then
  *      - clear dirty bit to prevent IO
  *      - remove from LRU
@@ -1080,6 +1080,7 @@ static int me_huge_page(struct page_state *ps, struct page *p)
        int res;
        struct page *hpage = compound_head(p);
        struct address_space *mapping;
+       bool extra_pins = false;
 
        if (!PageHuge(hpage))
                return MF_DELAYED;
@@ -1087,6 +1088,8 @@ static int me_huge_page(struct page_state *ps, struct page *p)
        mapping = page_mapping(hpage);
        if (mapping) {
                res = truncate_error_page(hpage, page_to_pfn(p), mapping);
+               /* The page is kept in page cache. */
+               extra_pins = true;
                unlock_page(hpage);
        } else {
                unlock_page(hpage);
@@ -1104,7 +1107,7 @@ static int me_huge_page(struct page_state *ps, struct page *p)
                }
        }
 
-       if (has_extra_refcount(ps, p, false))
+       if (has_extra_refcount(ps, p, extra_pins))
                res = MF_FAILED;
 
        return res;
@@ -1398,7 +1401,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
                                  int flags, struct page *hpage)
 {
        struct folio *folio = page_folio(hpage);
-       enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_SYNC;
+       enum ttu_flags ttu = TTU_IGNORE_MLOCK | TTU_SYNC | TTU_HWPOISON;
        struct address_space *mapping;
        LIST_HEAD(tokill);
        bool unmap_success;
@@ -1428,7 +1431,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
 
        if (PageSwapCache(p)) {
                pr_err("%#lx: keeping poisoned page in swap cache\n", pfn);
-               ttu |= TTU_IGNORE_HWPOISON;
+               ttu &= ~TTU_HWPOISON;
        }
 
        /*
@@ -1443,7 +1446,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
                if (page_mkclean(hpage)) {
                        SetPageDirty(hpage);
                } else {
-                       ttu |= TTU_IGNORE_HWPOISON;
+                       ttu &= ~TTU_HWPOISON;
                        pr_info("%#lx: corrupted page was clean: dropped without side effects\n",
                                pfn);
                }