[PATCH 2/3] mm: memory-failure: avoid pfn_valid() twice in soft_offline_page()

From: Kefeng Wang
Date: Fri Oct 21 2022 - 04:27:38 EST


Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid().

Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
---
mm/memory-failure.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b94152abb1c9..ca0199d0f79d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2554,10 +2554,10 @@ int soft_offline_page(unsigned long pfn, int flags)
bool try_again = true;
struct page *page;

- WARN_ON_ONCE(!pfn_valid(pfn) && (flags & MF_COUNT_INCREASED));
-
- if (!pfn_valid(pfn))
+ if (!pfn_valid(pfn)) {
+ WARN_ON_ONCE(flags & MF_COUNT_INCREASED);
return -ENXIO;
+ }

/* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */
page = pfn_to_online_page(pfn);
--
2.35.3