Commit e240ac52 authored by zhenwei pi's avatar zhenwei pi Committed by Andrew Morton

mm/memory-failure.c: simplify num_poisoned_pages_inc/dec

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.comSigned-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f0696cb4
...@@ -1132,6 +1132,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type, ...@@ -1132,6 +1132,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type,
{ {
trace_memory_failure_event(pfn, type, result); trace_memory_failure_event(pfn, type, result);
num_poisoned_pages_inc();
pr_err("Memory failure: %#lx: recovery action for %s: %s\n", pr_err("Memory failure: %#lx: recovery action for %s: %s\n",
pfn, action_page_types[type], action_name[result]); pfn, action_page_types[type], action_name[result]);
} }
...@@ -1587,8 +1588,6 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1587,8 +1588,6 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
goto out; goto out;
} }
num_poisoned_pages_inc();
/* /*
* Handling free hugepage. The possible race with hugepage allocation * Handling free hugepage. The possible race with hugepage allocation
* or demotion can be prevented by PageHWPoison flag. * or demotion can be prevented by PageHWPoison flag.
...@@ -1806,7 +1805,6 @@ int memory_failure(unsigned long pfn, int flags) ...@@ -1806,7 +1805,6 @@ int memory_failure(unsigned long pfn, int flags)
} }
hpage = compound_head(p); hpage = compound_head(p);
num_poisoned_pages_inc();
/* /*
* We need/can do nothing about count=0 pages. * We need/can do nothing about count=0 pages.
...@@ -1830,7 +1828,6 @@ int memory_failure(unsigned long pfn, int flags) ...@@ -1830,7 +1828,6 @@ int memory_failure(unsigned long pfn, int flags)
/* We lost the race, try again */ /* We lost the race, try again */
if (retry) { if (retry) {
ClearPageHWPoison(p); ClearPageHWPoison(p);
num_poisoned_pages_dec();
retry = false; retry = false;
goto try_again; goto try_again;
} }
...@@ -1906,8 +1903,7 @@ int memory_failure(unsigned long pfn, int flags) ...@@ -1906,8 +1903,7 @@ int memory_failure(unsigned long pfn, int flags)
*/ */
if (PageCompound(p)) { if (PageCompound(p)) {
if (retry) { if (retry) {
if (TestClearPageHWPoison(p)) ClearPageHWPoison(p);
num_poisoned_pages_dec();
unlock_page(p); unlock_page(p);
put_page(p); put_page(p);
flags &= ~MF_COUNT_INCREASED; flags &= ~MF_COUNT_INCREASED;
...@@ -1929,8 +1925,7 @@ int memory_failure(unsigned long pfn, int flags) ...@@ -1929,8 +1925,7 @@ int memory_failure(unsigned long pfn, int flags)
page_flags = p->flags; page_flags = p->flags;
if (hwpoison_filter(p)) { if (hwpoison_filter(p)) {
if (TestClearPageHWPoison(p)) TestClearPageHWPoison(p);
num_poisoned_pages_dec();
unlock_page(p); unlock_page(p);
put_page(p); put_page(p);
res = -EOPNOTSUPP; res = -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment