]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/memory-failure.c: simplify num_poisoned_pages_inc/dec
authorzhenwei pi <pizhenwei@bytedance.com>
Fri, 13 May 2022 03:23:10 +0000 (20:23 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 13 May 2022 14:20:19 +0000 (07:20 -0700)
Originally, do num_poisoned_pages_inc() in memory failure routine, use
num_poisoned_pages_dec() to rollback the number if filtered/ cancelled.

Suggested by Naoya, do num_poisoned_pages_inc() only in action_result(),
this make this clear and simple.

Link: https://lkml.kernel.org/r/20220509105641.491313-6-pizhenwei@bytedance.com
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c

index 7ee80350a9a5504255527d0a33bd4e90ba881f82..01f8b63d3621daec1cef3629d26190f6abbae866 100644 (file)
@@ -1132,6 +1132,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type,
 {
        trace_memory_failure_event(pfn, type, result);
 
+       num_poisoned_pages_inc();
        pr_err("Memory failure: %#lx: recovery action for %s: %s\n",
                pfn, action_page_types[type], action_name[result]);
 }
@@ -1587,8 +1588,6 @@ retry:
                goto out;
        }
 
-       num_poisoned_pages_inc();
-
        /*
         * Handling free hugepage.  The possible race with hugepage allocation
         * or demotion can be prevented by PageHWPoison flag.
@@ -1806,7 +1805,6 @@ try_again:
        }
 
        hpage = compound_head(p);
-       num_poisoned_pages_inc();
 
        /*
         * We need/can do nothing about count=0 pages.
@@ -1830,7 +1828,6 @@ try_again:
                                        /* We lost the race, try again */
                                        if (retry) {
                                                ClearPageHWPoison(p);
-                                               num_poisoned_pages_dec();
                                                retry = false;
                                                goto try_again;
                                        }
@@ -1906,8 +1903,7 @@ try_again:
         */
        if (PageCompound(p)) {
                if (retry) {
-                       if (TestClearPageHWPoison(p))
-                               num_poisoned_pages_dec();
+                       ClearPageHWPoison(p);
                        unlock_page(p);
                        put_page(p);
                        flags &= ~MF_COUNT_INCREASED;
@@ -1929,8 +1925,7 @@ try_again:
        page_flags = p->flags;
 
        if (hwpoison_filter(p)) {
-               if (TestClearPageHWPoison(p))
-                       num_poisoned_pages_dec();
+               TestClearPageHWPoison(p);
                unlock_page(p);
                put_page(p);
                res = -EOPNOTSUPP;