From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 625C243B6C7 for ; Wed, 22 Jul 2026 09:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711001; cv=none; b=PR1vGkm63suR2VF7eyiik+nb7nODhL2iS/+rlAKA/VmZNcv3k+bjZuJLaCJzh/oqR5RLZl9aq7EAoRMVh+nbQoaX7o1t3fAm+j7LE6NtQwyZ99rrsRVD9kmcJkeheSLFdYetxJCTIk4N1sTbaPmDbPugu3yytO2/tMEWEqEkPGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711001; c=relaxed/simple; bh=y6l1nwwVfHA8o0HRz0wQMC79KsUWrEKZjuF/09NrFRQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=cCvvQvLRSNVlegCkiQpAkLbFUWwb/b2DSKJKrzP7x2rvmy5pZivpxFOSgUT1WTdy7JNMwxvRccVn0X67qBvXJEp1v7qt/Q5paCvl1L1ss9cRHLkba8tTek98Ldb2us7zOGVEhpoIuWh2j1uzYPelLDxCkBC7rCKNYojn5TKTzFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OMUG6G9A; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OMUG6G9A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 590771F000E9; Wed, 22 Jul 2026 09:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784711000; bh=LB1YvNIUdccnuadhTBME0b1wdoweU9sjcOMw+G1YPUs=; h=Date:Subject:From:To:Cc:References:In-Reply-To; b=OMUG6G9A0CrJ+g1RwqaNvBOi+c/wGmv5p1KyqABj0ZIa+CcdOwaylhu8HktFF5RSs rRs8k0zSh0MFh8jxE+BdFB3RYNgagb3VwPRuTING5/alWIKHIrTjm8f/XEQoYkGTU5 67ZQ+9o2bdnQnmBZgTlRva1JzxjgXF20KZHEuWAHektU29YK4UokYQrPQ1odGE9zdP fzSvK3+4xdSlikz+lmnSw6L1qntgHR9SXi2EDMLcroaZn7w0T8igoH216ZsRdiwUuB lurDu5dPVLBt+EQTaxgRCXCPomVLoNn5sWJU3dgK1Mkakmjq9hz+BIOxKKRIIls7CW 3ag/bvRjhDbbA== Message-ID: Date: Wed, 22 Jul 2026 11:03:12 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/5] Only free healthy pages in high-order has_hwpoisoned folio Content-Language: en-US From: "Vlastimil Babka (SUSE)" To: William Roche , "David Hildenbrand (Arm)" , Jiaqi Yan , linmiaohe@huawei.com, ljs@kernel.org, ziy@nvidia.com Cc: osalvador@kernel.org, harry.yoo@oracle.com, willy@infradead.org, osalvador@suse.de, jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com, tony.luck@intel.com, wangkefeng.wang@huawei.com, jane.chu@oracle.com, akpm@linux-foundation.org, muchun.song@linux.dev, liam@infradead.org, rientjes@google.com, duenwen@google.com, jthoughton@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rppt@kernel.org, shuah@kernel.org, surenb@google.com, mhocko@suse.com, boudewijn@delta-utec.com References: <20260705180714.3708947-1-jiaqiyan@google.com> <85cb7ea8-8116-4092-8310-69b61eb8602c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RNjHcBeqN+Me0zxRqYzRb8nGanHEkDyf4Im8DQM8d6vbyU+FcPmG4skud4kgS1zMHnlVd SXfSIwKC/hKgdHG8aBV7545Lz9X6Iohea+94wneD0aw/hqF+QWewGZhWJriWAZtvEkzNjQOi 4U9F/trLten/x7bpphDSnDMKJtITbtzATT1Dq7o7VpIUK1nCTQALMuMjKCdi8OdU/+V+R3O4 0PXWvX8qrvqYapVbZ+9KqT74FsuB0Ya9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: <1dea7b3c-7740-474d-b9d4-cd2baf47f181@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/22/26 10:27, Vlastimil Babka (SUSE) wrote: > On 7/17/26 15:06, William Roche wrote: >> On 7/17/26 12:18, David Hildenbrand (Arm) wrote: >>> On 7/5/26 20:07, Jiaqi Yan wrote: >>>> At the end of dissolve_free_hugetlb_folio(), a free HugeTLB >>>> folio becomes non-HugeTLB and is released to buddy allocator >>>> as a high-order folio, e.g. a folio that contains 262144 pages >>>> if the folio was a 1G HugeTLB hugepage. >>>> >>>> This is problematic if the HugeTLB hugepage contained HWPoison >>>> subpages. In that case, since buddy allocator does not check >>>> HWPoison for non-zero-order folio, the raw HWPoison page can >>>> be given out with its buddy page and be re-used by either >>>> kernel or userspace. >>> >>> I still don't like the complexity of this, in particular, as we have different >>> mechanisms in the page allocator already to try handling this, >>> >>> We also do have cases where we set the hwpoison bit, while a page is just about >>> to get allocated from the buddy. So before we take it off the buddy, we might >>> just hand out the page. >>> >>> check_new_pages() seems to check for PageHWPoison() and make us not hand out >>> such pages. It's guarded by "check_pages" but it seems to do exactly what we are >>> looking for, now? >> >> >> Just adding a comment about this aspect: >> The check_new_pages() mechanism used by the __rmqueue functions should >> filter these pages out, but this has been disabled by default in 2023 >> with: >> [PATCH] mm, page_alloc: reduce page alloc/free sanity checks >> https://lore.kernel.org/all/20230216095131.17336-1-vbabka@suse.cz >> >> So it would need to be enabled back, taking some of the performance hit. >> (and I personally think that it has to be done) > > Would it truly fix the issue, or rather there would still be a race window > left where we check that there's no hwpoison flag in the re-enabled check, > and only then someone sets it? > > Also, can the hardware actually detect a problem with a page that nobody > accesses? I guess if yes, it's only in some corner cases. > > So I'm wary about penalizing the allocator paths again. If the page is in > the buddy allocator, shouldn't it be isolated away as part of setting the > hwpoison? I thought we already did that? Looking at the code, seems soft_offline_page() tries to take a refcount first and then sets the hwpoison flag, so it should be completely race-free wrt the page allocator. memory_failure() seems to start with TestSetPageHWPoison() and only then tries to get the refcount. Wonder if it should be that way. > So assuming we don't just leave > hwpoison pages in the buddy and this is only about some small race window > where it's being taken away from the buddy? Then the extra check would only > make a small window smaller, but is it worth it? > >> A note about the related project: >> This patch is an addition to the "mm: memfd/hugetlb: introduce >> memfd-based userspace MFR policy" >> project -- recycling the impacted hugetlb pages. >> >> I do think that "memfd-based userspace MFR policy" is a valuable >> enhancement, and if the impacted large page can be more easily recycled >> enabling check_new_pages() it's even better ! >> >> HTH. >