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

Message ID 20221021084611.53765-2-wangkefeng.wang@huawei.com
State New
Headers
Series [1/3] mm: memory-failure: make put_ref_page() more useful |

Commit Message

Kefeng Wang Oct. 21, 2022, 8:46 a.m. UTC
  Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid().

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

Comments

HORIGUCHI NAOYA(堀口 直也) Oct. 23, 2022, 11:39 p.m. UTC | #1
On Fri, Oct 21, 2022 at 04:46:10PM +0800, Kefeng Wang wrote:
> Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
  
Miaohe Lin Oct. 25, 2022, 2:55 a.m. UTC | #2
On 2022/10/21 16:46, Kefeng Wang wrote:
> Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks,
Miaohe Lin
  

Patch

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);