From: zhenwei pi <pizhenwei@bytedance.com>
To: akpm@linux-foundation.org, naoya.horiguchi@nec.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
zhenwei pi <pizhenwei@bytedance.com>
Subject: [PATCH v2 5/5] mm/memory-failure.c: simplify num_poisoned_pages_inc/dec
Date: Mon, 9 May 2022 18:56:41 +0800 [thread overview]
Message-ID: <20220509105641.491313-6-pizhenwei@bytedance.com> (raw)
In-Reply-To: <20220509105641.491313-1-pizhenwei@bytedance.com>
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.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
mm/memory-failure.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index ed280ef5473d..2d590cba412c 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1133,6 +1133,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]);
}
@@ -1588,8 +1589,6 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
goto out;
}
- num_poisoned_pages_inc();
-
/*
* Handling free hugepage. The possible race with hugepage allocation
* or demotion can be prevented by PageHWPoison flag.
@@ -1815,7 +1814,6 @@ int memory_failure(unsigned long pfn, int flags)
}
hpage = compound_head(p);
- num_poisoned_pages_inc();
/*
* We need/can do nothing about count=0 pages.
@@ -1839,7 +1837,6 @@ int memory_failure(unsigned long pfn, int flags)
/* We lost the race, try again */
if (retry) {
ClearPageHWPoison(p);
- num_poisoned_pages_dec();
retry = false;
goto try_again;
}
@@ -1915,8 +1912,7 @@ int memory_failure(unsigned long pfn, int flags)
*/
if (PageCompound(p)) {
if (retry) {
- if (TestClearPageHWPoison(p))
- num_poisoned_pages_dec();
+ ClearPageHWPoison(p);
unlock_page(p);
put_page(p);
flags &= ~MF_COUNT_INCREASED;
@@ -1938,8 +1934,7 @@ int memory_failure(unsigned long pfn, int flags)
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;
--
2.20.1
next prev parent reply other threads:[~2022-05-09 11:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 10:56 [PATCH v2 0/5] memory-failure: fix hwpoison_filter zhenwei pi
2022-05-09 10:56 ` [PATCH v2 1/5] mm/memory-failure.c: move clear_hwpoisoned_pages zhenwei pi
2022-05-09 10:56 ` [PATCH v2 2/5] mm/memory-failure.c: simplify num_poisoned_pages_dec zhenwei pi
2022-05-09 10:56 ` [PATCH v2 3/5] mm/memory-failure.c: add hwpoison_filter for soft offline zhenwei pi
2022-05-11 8:18 ` HORIGUCHI NAOYA(堀口 直也)
2022-05-09 10:56 ` [PATCH v2 4/5] mm/hwpoison: disable hwpoison filter during removing zhenwei pi
2022-05-11 8:18 ` HORIGUCHI NAOYA(堀口 直也)
2022-05-09 10:56 ` zhenwei pi [this message]
2022-05-11 8:20 ` [PATCH v2 5/5] mm/memory-failure.c: simplify num_poisoned_pages_inc/dec HORIGUCHI NAOYA(堀口 直也)
2022-05-11 8:18 ` zhenwei pi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220509105641.491313-6-pizhenwei@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).