]> www.infradead.org Git - nvme.git/commitdiff
mm/memory-failure: improve memory failure action_result messages
authorJane Chu <jane.chu@oracle.com>
Fri, 24 May 2024 21:53:04 +0000 (15:53 -0600)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 02:29:57 +0000 (19:29 -0700)
Added two explicit MF_MSG messages describing failure in
get_hwpoison_page.  Attemped to document the definition of various action
names, and made a few adjustment to the action_result() calls.

Link: https://lkml.kernel.org/r/20240524215306.2705454-4-jane.chu@oracle.com
Signed-off-by: Jane Chu <jane.chu@oracle.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Oscar Salvador <oalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
include/ras/ras_event.h
mm/memory-failure.c

index 99174fac3d47a52ab333d40afb5af7d5ef7f3673..f4bf94ca99e344e1a18bafb7728fc67a80f89cb6 100644 (file)
@@ -4096,6 +4096,7 @@ enum mf_action_page_type {
        MF_MSG_DIFFERENT_COMPOUND,
        MF_MSG_HUGE,
        MF_MSG_FREE_HUGE,
+       MF_MSG_GET_HWPOISON,
        MF_MSG_UNMAP_FAILED,
        MF_MSG_DIRTY_SWAPCACHE,
        MF_MSG_CLEAN_SWAPCACHE,
@@ -4109,6 +4110,7 @@ enum mf_action_page_type {
        MF_MSG_BUDDY,
        MF_MSG_DAX,
        MF_MSG_UNSPLIT_THP,
+       MF_MSG_ALREADY_POISONED,
        MF_MSG_UNKNOWN,
 };
 
index 7c47151d5c72be96d37513610e8689718239348e..cf7f19b7ce64c446c2ed9303310d7f9884772cac 100644 (file)
@@ -360,6 +360,7 @@ TRACE_EVENT(aer_event,
        EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
        EM ( MF_MSG_HUGE, "huge page" )                                 \
        EM ( MF_MSG_FREE_HUGE, "free huge page" )                       \
+       EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" )                 \
        EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" )             \
        EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" )           \
        EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" )           \
@@ -373,6 +374,7 @@ TRACE_EVENT(aer_event,
        EM ( MF_MSG_BUDDY, "free buddy page" )                          \
        EM ( MF_MSG_DAX, "dax page" )                                   \
        EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" )                        \
+       EM ( MF_MSG_ALREADY_POISONED, "already poisoned" )              \
        EMe ( MF_MSG_UNKNOWN, "unknown page" )
 
 /*
index 0ce5f5176435ffbdf9b276ebf3ada01de5e22b2c..7f29f1adba21bd8e9afbddb9e1d6f9c08d21c450 100644 (file)
@@ -879,6 +879,28 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn,
        return ret > 0 ? -EHWPOISON : -EFAULT;
 }
 
+/*
+ * MF_IGNORED - The m-f() handler marks the page as PG_hwpoisoned'ed.
+ * But it could not do more to isolate the page from being accessed again,
+ * nor does it kill the process. This is extremely rare and one of the
+ * potential causes is that the page state has been changed due to
+ * underlying race condition. This is the most severe outcomes.
+ *
+ * MF_FAILED - The m-f() handler marks the page as PG_hwpoisoned'ed.
+ * It should have killed the process, but it can't isolate the page,
+ * due to conditions such as extra pin, unmap failure, etc. Accessing
+ * the page again may trigger another MCE and the process will be killed
+ * by the m-f() handler immediately.
+ *
+ * MF_DELAYED - The m-f() handler marks the page as PG_hwpoisoned'ed.
+ * The page is unmapped, and is removed from the LRU or file mapping.
+ * An attempt to access the page again will trigger page fault and the
+ * PF handler will kill the process.
+ *
+ * MF_RECOVERED - The m-f() handler marks the page as PG_hwpoisoned'ed.
+ * The page has been completely isolated, that is, unmapped, taken out of
+ * the buddy system, or hole-punnched out of the file mapping.
+ */
 static const char *action_name[] = {
        [MF_IGNORED] = "Ignored",
        [MF_FAILED] = "Failed",
@@ -893,6 +915,7 @@ static const char * const action_page_types[] = {
        [MF_MSG_DIFFERENT_COMPOUND]     = "different compound page after locking",
        [MF_MSG_HUGE]                   = "huge page",
        [MF_MSG_FREE_HUGE]              = "free huge page",
+       [MF_MSG_GET_HWPOISON]           = "get hwpoison page",
        [MF_MSG_UNMAP_FAILED]           = "unmapping failed page",
        [MF_MSG_DIRTY_SWAPCACHE]        = "dirty swapcache page",
        [MF_MSG_CLEAN_SWAPCACHE]        = "clean swapcache page",
@@ -906,6 +929,7 @@ static const char * const action_page_types[] = {
        [MF_MSG_BUDDY]                  = "free buddy page",
        [MF_MSG_DAX]                    = "dax page",
        [MF_MSG_UNSPLIT_THP]            = "unsplit thp",
+       [MF_MSG_ALREADY_POISONED]       = "already poisoned",
        [MF_MSG_UNKNOWN]                = "unknown page",
 };
 
@@ -1013,12 +1037,13 @@ static int me_kernel(struct page_state *ps, struct page *p)
 
 /*
  * Page in unknown state. Do nothing.
+ * This is a catch-all in case we fail to make sense of the page state.
  */
 static int me_unknown(struct page_state *ps, struct page *p)
 {
        pr_err("%#lx: Unknown page state\n", page_to_pfn(p));
        unlock_page(p);
-       return MF_FAILED;
+       return MF_IGNORED;
 }
 
 /*
@@ -2055,6 +2080,7 @@ retry:
                if (flags & MF_ACTION_REQUIRED) {
                        folio = page_folio(p);
                        res = kill_accessing_process(current, folio_pfn(folio), flags);
+                       action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED);
                }
                return res;
        } else if (res == -EBUSY) {
@@ -2062,7 +2088,7 @@ retry:
                        flags |= MF_NO_RETRY;
                        goto retry;
                }
-               return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED);
+               return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
        }
 
        folio = page_folio(p);
@@ -2097,7 +2123,7 @@ retry:
 
        if (!hwpoison_user_mappings(folio, p, pfn, flags)) {
                folio_unlock(folio);
-               return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);
+               return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED);
        }
 
        return identify_page_state(pfn, p, page_flags);
@@ -2231,6 +2257,7 @@ try_again:
                        res = kill_accessing_process(current, pfn, flags);
                if (flags & MF_COUNT_INCREASED)
                        put_page(p);
+               action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED);
                goto unlock_mutex;
        }
 
@@ -2267,7 +2294,7 @@ try_again:
                        }
                        goto unlock_mutex;
                } else if (res < 0) {
-                       res = action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED);
+                       res = action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
                        goto unlock_mutex;
                }
        }
@@ -2363,7 +2390,7 @@ try_again:
         * Abort on fail: __filemap_remove_folio() assumes unmapped page.
         */
        if (!hwpoison_user_mappings(folio, p, pfn, flags)) {
-               res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);
+               res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED);
                goto unlock_page;
        }