From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E98C03B3BEC for ; Fri, 17 Jul 2026 07:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784273854; cv=none; b=LNsZmx0iBMNlCKH6UAXDGqCqWKch1KqM4aDsWGBkMw35gNlDfT13BmtMZRzOf2yg8KkasCbYRTs6r3F7WTVSyWzWJRXg9CZuPlpD+Eq1FZsGtncf9GrvmbviSPu96YfkNFCTOGPcf0YlLuSVu8kd23gj3uHGSK1RpuEW9BuN20g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784273854; c=relaxed/simple; bh=KlUuz5Iy4pMmLFUxem42s3Ew+5FKmpGojamnrxbJpI4=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=T872Na1UcxJfOzVYGuGo2UssV1vQuICmWusnGIqoRAY/KiCXpfoI6wnj/k5G5OfP6p3xHkZCSmB4b5tN6FLuG/GndWdH+cB2hEQ3cdZ7dme//OwfgLQqoXFNqwI/f8IpJgs0DLglkZjwu4gyjareZxeRKiheJRMPWqSDRSYwOBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=rFkaBPk9; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="rFkaBPk9" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=sqcItdVwMdtqq+wQZkw4sF9Fwwk8c+e74Gq/J87v9jw=; b=rFkaBPk9C6M50Fq7oZzEyIF/MnLyqwbGB4szaJpi4v/YgbCy7mkm0u19US7N/d/P/wgeiXeKA H3as/zBVfkjwCIuuum0HjPqtqzaD5Xb1cYyEP+Fr/CEnRLSsl2KAt0p9T/UoVSAJm7AHzUIHFOq KxjnLRi9Qg2Xx9XxSfsIsWk= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4h1hMn5h9wzLlTg; Fri, 17 Jul 2026 15:28:05 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 544284058E; Fri, 17 Jul 2026 15:37:25 +0800 (CST) Received: from kwepemq500010.china.huawei.com (7.202.194.235) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 17 Jul 2026 15:37:12 +0800 Received: from [10.173.124.160] (10.173.124.160) by kwepemq500010.china.huawei.com (7.202.194.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 17 Jul 2026 15:37:10 +0800 Subject: Re: [PATCH v6 4/5] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page To: Jiaqi Yan CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20260705180714.3708947-1-jiaqiyan@google.com> <20260705180714.3708947-5-jiaqiyan@google.com> From: Miaohe Lin Message-ID: Date: Fri, 17 Jul 2026 15:37:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260705180714.3708947-5-jiaqiyan@google.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemq500010.china.huawei.com (7.202.194.235) On 2026/7/6 2:07, Jiaqi Yan wrote: > Now that HWPoison subpage(s) within HugeTLB page will be rejected by > buddy allocator during dissolve_free_hugetlb_folio(), there is no > need to drain_all_pages() and take_page_off_buddy() anymore. In fact, > calling take_page_off_buddy() after dissolve_free_hugetlb_folio() > succeeded returns false, making caller think __page_handle_poison() > failed. > > Add __hugepage_handle_poison() and replace __page_handle_poison() at > HugeTLB specific call sites. The being handled HugeTLB page either > is free at the moment of try_memory_failure_hugetlb(), or becomes > free at the moment of me_huge_page(). > > Signed-off-by: Jiaqi Yan > --- > mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++------ > 1 file changed, 30 insertions(+), 6 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 3d15b4c1b694..a37b67550718 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -174,6 +174,30 @@ static struct rb_root_cached pfn_space_itree = RB_ROOT_CACHED; > static DEFINE_MUTEX(pfn_space_lock); > > /* > + * Only for a HugeTLB page being handled by memory_failure(). The key > + * difference to soft_offline() is that, no HWPoison subpage will make > + * into buddy allocator after a successful dissolve_free_hugetlb_folio(), > + * so take_page_off_buddy() is unnecessary. > + */ > +static int __hugepage_handle_poison(struct page *page) > +{ > + struct folio *folio = page_folio(page); > + > + /* > + * Can't use dissolve_free_hugetlb_folio() without a reliable > + * raw_hwp_list telling which subpage is HWPoison. So do not free > + * them to the buddy allocator. dequeue_hugetlb_folio_node_exact() > + * will ensure to never re-allocate this hugepage. > + */ > + if (folio_test_hugetlb_raw_hwp_unreliable(folio)) > + /* raw_hwp_list becomes unreliable when kmalloc() fails. */ > + return -ENOMEM; There are some branches in __update_and_free_hugetlb_folio that will leave hugetlb folio untouched: static void __update_and_free_hugetlb_folio(struct hstate *h, struct folio *folio) { bool clear_flag = folio_test_hugetlb_vmemmap_optimized(folio); if (hstate_is_gigantic_no_runtime(h)) return;<-- 1 /* * If we don't know which subpages are hwpoisoned, we can't free * the hugepage, so it's leaked intentionally. */ if (folio_test_hugetlb_raw_hwp_unreliable(folio)) return;<-- 2 /* * If folio is not vmemmap optimized (!clear_flag), then the folio * is no longer identified as a hugetlb page. hugetlb_vmemmap_restore_folio * can only be passed hugetlb pages and will BUG otherwise. */ if (clear_flag && hugetlb_vmemmap_restore_folio(h, folio)) { spin_lock_irq(&hugetlb_lock); /* * If we cannot allocate vmemmap pages, just refuse to free the * page and put the page back on the hugetlb free list and treat * as a surplus page. */ add_hugetlb_folio(h, folio, true); spin_unlock_irq(&hugetlb_lock); return;<-- 3 } But __update_and_free_hugetlb_folio has no return value. So caller can't know exactly whether hugetlb folio is indeed dissolved. So maybe we need a way to detect whether hugetlb folio is indeed dissolved? Note before this patch, take_page_off_buddy will fail if hugetlb folio is not dissolved. Thanks. .