Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6348560iog; Thu, 23 Jun 2022 17:28:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sUNXVUQL8SGyZu0UqC2S4fUyzsgb1X5LOMtKs2ZjAza3nuDo2+C/8dhCY0GWE8jyKsD25/ X-Received: by 2002:a65:42cc:0:b0:3a9:f71f:33f9 with SMTP id l12-20020a6542cc000000b003a9f71f33f9mr9476451pgp.391.1656030534345; Thu, 23 Jun 2022 17:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656030534; cv=none; d=google.com; s=arc-20160816; b=EUV6bjuqibnxqLa4aMc+dHbfG02Pm2SP3g0VU4mztuPVNh7+VKVAPMhC42GBK5AyaT 5gG0+a7/bZRJtvs726sRUBv/c4m6wWTHJF08V6q1YEkYiU+WfP2/G7LbHr8mvuaInHbf fmegEVB5v0wZy/utYKHMPAMOWHlHvo1e3ukdgaGzeSs2J1zizX5wUDUmo7fq3XJ30fkI Uix6OuUNdtk6nBVdUeN5RmEDcFwH8uZCvXlFpMR3mp0rtcOmGrbEocnQPYmutULitMnK OERHUG+pSfBF2O/fUCAnNGzYBo5R3BW93NYrDeEIc/zBu0iqI00txQw0aw5iELCC8okN xf0w== 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=LG1rSzGEsPK4iv+N/lwp5PXQGNIYUtfM/aAuTYkg0vc=; b=zaNtR8B4Mh/DeYjJ0JzSxyJfSGHTOclx6y3I/W2pqKi/tBuc3fPIEDu5gh0+avRQeg ddi2HKp/TdzCGxm8PJ+J9PR+lZov0qGYJRy9kWa7fAfUZFC0Gy4GTqiCQk8WJOyYLMMq 8If9UfruziFooC2JSc9Kcqn4Eu8QdWC2a/Wu/ZT5zKPtu9P1cjcsRl7juTi64se+nlIc MshZLzDa6AAUGinqIzdlXNSMMnTVdduR7zE8TyV8GMlJ5RKV2//VAn0KxGwOSqZCGU5W BIbabQ5kBOVcFmei1W3FNnjd3clSOx7ITJ3zhNt3S8EZop4l87m6qY/wuQDTvHb2wvof oQsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kp5Fq94l; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a056a000b5200b0051b5d39f016si853660pfo.56.2022.06.23.17.28.40; Thu, 23 Jun 2022 17:28:54 -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=@gmail.com header.s=20210112 header.b=kp5Fq94l; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiFWXxI (ORCPT + 99 others); Thu, 23 Jun 2022 19:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiFWXw4 (ORCPT ); Thu, 23 Jun 2022 19:52:56 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE1910F1 for ; Thu, 23 Jun 2022 16:52:53 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id h192so878265pgc.4 for ; Thu, 23 Jun 2022 16:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LG1rSzGEsPK4iv+N/lwp5PXQGNIYUtfM/aAuTYkg0vc=; b=kp5Fq94l6Q8wgGQCHb0XGJwN4XF5JHuSExD/vq+W4HulxPu4y7NpXpzk0sC4IbGOF0 M8KAGgZc5kObwch9yTED6BTWncP2yvMtbr+bH+KSPK3guq1ThRAzdHSa+W71rWfvYi5Y ysRgIgyiMWh4MKt7L42JrZc5NkKFssOV2e5P4ICRr7BACAKuoQ/eu+QswjxOjsF8Qh9L /9q19zgN4ONQWZgUIzp2zk9FPdJ7T/61qXbmDITGTyaGcabR3hZpeQjiZAfpcM4Id7Ms ZxiNLZtA8OmC0bfzSoEwTbnAiH5hXBWlOsZ/GgJaKy63TSCZUNEzfRNHl4QZ+uHeTTH/ Cbxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LG1rSzGEsPK4iv+N/lwp5PXQGNIYUtfM/aAuTYkg0vc=; b=Rf9POphUVuawOCUwtvG2fJ/qZr+RxT/6lKQlsnLl9gi1rP4qde5CE/l5dLzCo/+yWQ Ey63T8V1VTTFh+50hdFnxkSKWF3exqCF9OwuWSVTtYWuprBKTWplZZ44RJCOdoK5ruYg +I/cR6PBZgwBBJeFq4FArS9E5O7pF/bKrjr4eyLcJAOx7Zl4KRLPq0b/ueBvUYRBN7Kh JhPQM+pH0lD/MkhjaFV40Mb4O+uz/odJU05N26qdO8GHdFAc4IVBFks6p/XJ8ZxWur6b MstZ1g3qAx2/RfwjK8JCpX6I9u5+7oLAw8TI79POIYcV/JiZXihm5H/F0g47nzdrLBF1 e1HQ== X-Gm-Message-State: AJIora+uP2cs0XUNXKOiFrunz2B2UlX4gGeap2tQPK/huIIINbJo/KG+ KcI/JydZjHAhuuTRmaoYZA== X-Received: by 2002:a62:6410:0:b0:4f3:9654:266d with SMTP id y16-20020a626410000000b004f39654266dmr43077948pfb.59.1656028372725; Thu, 23 Jun 2022 16:52:52 -0700 (PDT) Received: from ik1-406-35019.vs.sakura.ne.jp (ik1-406-35019.vs.sakura.ne.jp. [153.127.16.23]) by smtp.gmail.com with ESMTPSA id r10-20020a170903020a00b00168eab11f67sm362571plh.94.2022.06.23.16.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 16:52:52 -0700 (PDT) From: Naoya Horiguchi X-Google-Original-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: [PATCH v2 8/9] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage Date: Fri, 24 Jun 2022 08:51:52 +0900 Message-Id: <20220623235153.2623702-9-naoya.horiguchi@linux.dev> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 --- mm/memory-failure.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index db85f644a1e3..fc7b83cb6468 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1046,7 +1046,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, @@ -1054,9 +1053,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; } } @@ -1704,9 +1705,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb */ if (res == 0) { unlock_page(head); - 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