Skip to content

Commit e240ac5

Browse files
pizhenweiakpm00
authored andcommitted
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/[email protected] Signed-off-by: zhenwei pi <[email protected]> Acked-by: Naoya Horiguchi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f0696cb commit e240ac5

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

mm/memory-failure.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type,
11321132
{
11331133
trace_memory_failure_event(pfn, type, result);
11341134

1135+
num_poisoned_pages_inc();
11351136
pr_err("Memory failure: %#lx: recovery action for %s: %s\n",
11361137
pfn, action_page_types[type], action_name[result]);
11371138
}
@@ -1587,8 +1588,6 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
15871588
goto out;
15881589
}
15891590

1590-
num_poisoned_pages_inc();
1591-
15921591
/*
15931592
* Handling free hugepage. The possible race with hugepage allocation
15941593
* or demotion can be prevented by PageHWPoison flag.
@@ -1806,7 +1805,6 @@ int memory_failure(unsigned long pfn, int flags)
18061805
}
18071806

18081807
hpage = compound_head(p);
1809-
num_poisoned_pages_inc();
18101808

18111809
/*
18121810
* We need/can do nothing about count=0 pages.
@@ -1830,7 +1828,6 @@ int memory_failure(unsigned long pfn, int flags)
18301828
/* We lost the race, try again */
18311829
if (retry) {
18321830
ClearPageHWPoison(p);
1833-
num_poisoned_pages_dec();
18341831
retry = false;
18351832
goto try_again;
18361833
}
@@ -1906,8 +1903,7 @@ int memory_failure(unsigned long pfn, int flags)
19061903
*/
19071904
if (PageCompound(p)) {
19081905
if (retry) {
1909-
if (TestClearPageHWPoison(p))
1910-
num_poisoned_pages_dec();
1906+
ClearPageHWPoison(p);
19111907
unlock_page(p);
19121908
put_page(p);
19131909
flags &= ~MF_COUNT_INCREASED;
@@ -1929,8 +1925,7 @@ int memory_failure(unsigned long pfn, int flags)
19291925
page_flags = p->flags;
19301926

19311927
if (hwpoison_filter(p)) {
1932-
if (TestClearPageHWPoison(p))
1933-
num_poisoned_pages_dec();
1928+
TestClearPageHWPoison(p);
19341929
unlock_page(p);
19351930
put_page(p);
19361931
res = -EOPNOTSUPP;

0 commit comments

Comments
 (0)