Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1144149imk; Sun, 3 Jul 2022 18:40:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ugVVj8uR/5RlJfRIVUIt2OnjqnoFBI1y2vFY8SreC4goxF0FJRVFP2wU5rIgEa+Lt4OcyR X-Received: by 2002:a17:906:4fc9:b0:726:f4e4:88e8 with SMTP id i9-20020a1709064fc900b00726f4e488e8mr25617217ejw.57.1656898850142; Sun, 03 Jul 2022 18:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656898850; cv=none; d=google.com; s=arc-20160816; b=HYuxEtkWYM2M6wuH6CTkgjI4Ew0gqXSjoyBBx6sz4hDgYPb3oQidkFuZmsN6+otgsx t8gXCWfD/6cM6MWt99sHHdHh4f/TrXDwBex44nbolz8+AJaeGrcZzq7B++XcWP+BCGYk CgrRQREHQQZ+RFBF+hb/f+6nJBeIoIIgIp99iQ5S1yzxtTRAH78fJ7a4/MrimfC90iqu zizCv5Xmn+owXYdX2ZCcYKy8TPdYstTiBt4L7inqxlfAG8zccKq2UQzMb8lH4awScKsf 5RSbTfZ4dqlsVfaNvFm3khhg+8iWTBqqM4Ybth1JinZY+KorBeHD66mo/zEhBqkTmOJJ goiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=heS02K7z+r8PEdKG4MUWA7zX+tLrnPdwPTD094o8JOg=; b=uQt709H1puMuNhPtt753wVWFfDZTAQDLfjTFv3pQt4BTaS9MCiDnfjKkULDWWa+dG3 1atu7DyyTdpUOjNFk9FP4tbJZRwU4Irf8h9Hc6+JsjIe197Zac8FoGbZDi9w4oa9Pe94 /3WrjNDM3Dva2xiItpnZ+BBoHTjQL5NGQdxxoNpLy18zy3YfpdBZtJjHZNxGPb+tpH16 KLOwJxvvP9A+qSHy+Uv1KjJSG/nMK8tpdUgJvxsxQBHo06N5hXmr8pBF66rALee8/DWY doVeZDexuSiY0P9NvrUWbP8Kv+VfKUN2SGC1571z9rBwDDXg5xInHHsEYqckLpnDegjh 6yOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jRaTv0Vw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r23-20020aa7cfd7000000b00435c7fa01d6si27602540edy.77.2022.07.03.18.40.24; Sun, 03 Jul 2022 18:40:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jRaTv0Vw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbiGDBeF (ORCPT + 99 others); Sun, 3 Jul 2022 21:34:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbiGDBd7 (ORCPT ); Sun, 3 Jul 2022 21:33:59 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E0AFF9 for ; Sun, 3 Jul 2022 18:33:58 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1656898437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=heS02K7z+r8PEdKG4MUWA7zX+tLrnPdwPTD094o8JOg=; b=jRaTv0VwNQxjDdV98OfbIxmp1MAqAgbAH/qQR3ItolbymLwEHvIL2qLSHpHa3s3kJ1koVp vAJYGZyR5HC+qRzOJjiyzX4i5zDxgzsy7/gMyfFESteNaKoW7hSeDlkdt2JXRG43voSdKQ 9GgP3nwITYE2BxtTb5MQw7I2+fTbado= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Mike Kravetz , Miaohe Lin , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [mm-unstable PATCH v4 8/9] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage Date: Mon, 4 Jul 2022 10:33:11 +0900 Message-Id: <20220704013312.2415700-9-naoya.horiguchi@linux.dev> In-Reply-To: <20220704013312.2415700-1-naoya.horiguchi@linux.dev> References: <20220704013312.2415700-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naoya Horiguchi Currently if memory_failure() (modified to remove blocking code with subsequent patch) is called on a page in some 1GB hugepage, memory error handling fails and the raw error page gets into leaked state. The impact is small in production systems (just leaked single 4kB page), but this limits the testability because unpoison doesn't work for it. We can no longer create 1GB hugepage on the 1GB physical address range with such leaked pages, that's not useful when testing on small systems. When a hwpoison page in a 1GB hugepage is handled, it's caught by the PageHWPoison check in free_pages_prepare() because the 1GB hugepage is broken down into raw error pages before coming to this point: if (unlikely(PageHWPoison(page)) && !order) { ... return false; } Then, the page is not sent to buddy and the page refcount is left 0. Originally this check is supposed to work when the error page is freed from page_handle_poison() (that is called from soft-offline), but now we are opening another path to call it, so the callers of __page_handle_poison() need to handle the case by considering the return value 0 as success. Then page refcount for hwpoison is properly incremented so unpoison works. Signed-off-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- v2 -> v3: - remove "res = MF_FAILED" in try_memory_failure_hugetlb (by Miaohe) --- mm/memory-failure.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c8939a39fbe6..f095d55f40bc 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1084,7 +1084,6 @@ static int me_huge_page(struct page_state *ps, struct page *p) res = truncate_error_page(hpage, page_to_pfn(p), mapping); unlock_page(hpage); } else { - res = MF_FAILED; unlock_page(hpage); /* * migration entry prevents later access on error hugepage, @@ -1092,9 +1091,11 @@ static int me_huge_page(struct page_state *ps, struct page *p) * subpages. */ put_page(hpage); - if (__page_handle_poison(p) > 0) { + if (__page_handle_poison(p) >= 0) { page_ref_inc(p); res = MF_RECOVERED; + } else { + res = MF_FAILED; } } @@ -1855,10 +1856,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb */ if (res == 0) { unlock_page(head); - res = MF_FAILED; - if (__page_handle_poison(p) > 0) { + if (__page_handle_poison(p) >= 0) { page_ref_inc(p); res = MF_RECOVERED; + } else { + res = MF_FAILED; } action_result(pfn, MF_MSG_FREE_HUGE, res); return res == MF_RECOVERED ? 0 : -EBUSY; -- 2.25.1