Re: [PATCH v8 10/15] mm: Check individual hugetlb pages for poison

Gregory Price <[email protected]>
Newsgroups org.kernel.vger.linux-fsdevel,org.kvack.linux-mm
Message-ID <anI5bPVScck1WXvh@gourry-fedora-PF4VCD3F>
On Fri, Jul 31, 2026 at 09:07:55PM +0100, Matthew Wilcox (Oracle) wrote:
> +/*
> + * We have no reference on the folio containing this page.
> + * The hugetlb_lock keeps hugetlb folios from being freed.
> + */
> +bool hugetlb_unref_page_hwpoison(const struct page *page)
> +{
> +	const struct folio *folio;
> +	unsigned long flags;
> +	bool ret;
> +
> +	spin_lock_irqsave(&hugetlb_lock, flags);
> +	folio = page_folio(page);
> +	if (!folio_test_huge_poison(folio)) {
> +		ret = PageHWPoison(page);
> +		goto unlock;
> +	}
> +
> +	ret = precise_page_poisoned(folio, page);
> +unlock:
> +	spin_unlock_irqrestore(&hugetlb_lock, flags);
> +	return ret;
> +}
> +

I ended up with the same question as sashiko - i think this behavior
implies we must hold a reference on the page, otherwise the folio can
be invalid and all these accesses are unsafe.

But that must be the existing behavior for poison checks like this, so
this is at least no worse. Not sure it's worth addressing.

Reviewed-by: Gregory Price (Meta) <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.