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 15F1034BA5A for ; Thu, 23 Jul 2026 17:16:09 +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=1784826971; cv=none; b=T8E/w4q6MWGnQ3LUdls7OjDFSP41Cp3Q4pzeyeHa1OoBllyk259t7SBepUBJTcUuM4jRClm+3CD00WPRCXUSrkoF48OKh6rDAKuNymVf7E7UfVxLHiQP9k9sh+PsVcBLpI7pYOrVjVgK+3yqz58SJZHZRFTJSD1kIX+gQ9yRDwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784826971; c=relaxed/simple; bh=AK10jURIQ+HPTzPiy0iTvEk0sQ9qjmXwtj5WT0ArdGk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dK6GMWoQU52AzKqDCdomZV/hUWR/EKv5CpNlgFIeUz429HW02DFM6ZsXywkP5kisdwRp37EwHtnqIU7FKZxpZrdbHJcpeNDhCqAE/vXZygI1gjHMl4HXLfPGW7a4uVcAhTCNt/rK9JxLdZU6AE3tT+iyrLTMGr8wU1+DDmdPdKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a91Ja4pk; 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="a91Ja4pk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 981DC1F000E9; Thu, 23 Jul 2026 17:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784826969; bh=PPI0I1SZnTvGKpqikQwr8QSqAd3TK/AxzSKHu/nFwbM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=a91Ja4pkPFklSAR319qDqsm3kB/UTDdEb6q6mXYT2v0zJDeC8m0klOVfMIVWdYKsB /Odo9jiAysHptRQg9KgDpdWt6UgCsAL9P3iXgJaTD4VtpTXTFSLbBjvbU4aUlQQTTC tAse9zBNc+cNyYdP3BjIcyBboBU7D8G5KdudWDETco7pCQCp8sIYAgQ8t/05Pq7bwK jR5p9TXRn8mRxz40fSLv+P4/irIfW8AFpMBDOJd00rRPMzOGo88nWYms5GyBk117FJ uJyTZpYftzt3zIB4n+XALKGwsBalzzduTdZNIM+G7/7BYIEpGQcx1JWKJgmsgmPqC4 PG3Lerzt5KkCg== Date: Thu, 23 Jul 2026 18:15:50 +0100 From: "Lorenzo Stoakes (ARM)" To: Dev Jain Cc: akpm@linux-foundation.org, david@kernel.org, muchun.song@linux.dev, osalvador@suse.de, riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryan.roberts@arm.com, anshuman.khandual@arm.com Subject: Re: [PATCH v2 1/5] mm/rmap: convert page -> folio for hwpoison checks Message-ID: References: <20260710055915.638659-1-dev.jain@arm.com> <20260710055915.638659-2-dev.jain@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260710055915.638659-2-dev.jain@arm.com> On Fri, Jul 10, 2026 at 05:59:10AM +0000, Dev Jain wrote: > try_to_unmap() receives hugetlb folios only from the hwpoison path. Horrifying :) > hugetlb_update_hwpoison() sets the hugetlb folio's head-page > hwpoison bit, and page_vma_mapped_walk() reports the hugetlb mapping at > the head PFN, so the previous PageHWPoison(subpage) check happened to > work for hugetlb. > > For non-hugetlb folios, unmap_poisoned_folio() currently rejects large > folios before calling try_to_unmap(). Hence it is always the case that > if try_to_unmap_one() handles an hwpoisoned folio, then the head page is > marked with the poison bit. > > Therefore, convert the poisoned subpage checks to folio_test_hwpoison(). > > No functional change intended, except that, while at it, > convert VM_BUG_* to VM_WARN_*. > > Acked-by: David Hildenbrand (Arm) > Signed-off-by: Dev Jain Small nit below but generally LGTM so: Reviewed-by: Lorenzo Stoakes (ARM) > --- > mm/rmap.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 9939400e77c79..dbb077f8443e3 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -2122,10 +2122,11 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, > bool anon = folio_test_anon(folio); > > /* > - * The try_to_unmap() is only passed a hugetlb page > - * in the case where the hugetlb page is poisoned. > + * The try_to_unmap() is only passed a hugetlb folio > + * in the case where the hugetlb folio contains a > + * poisoned page. > */ > - VM_BUG_ON_PAGE(!PageHWPoison(subpage), subpage); > + VM_WARN_ON_FOLIO(!folio_test_hwpoison(folio), folio); > /* > * huge_pmd_unshare may unmap an entire PMD page. > * There is no way of knowing exactly which PMDs may > @@ -2204,7 +2205,11 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, > /* Update high watermark before we lower rss */ > update_hiwater_rss(mm); > > - if (PageHWPoison(subpage) && (flags & TTU_HWPOISON)) { > + /* > + * With TTU_HWPOISON, we only expect small folios or hugetlb > + * folios here for now. > + */ I think probably we can drop this? It seems implied by the code (David comment similarly I think? :) > + if (folio_test_hwpoison(folio) && (flags & TTU_HWPOISON)) { > pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); > if (folio_test_hugetlb(folio)) { > hugetlb_count_sub(folio_nr_pages(folio), mm); > -- > 2.43.0 > Cheers, Lorenzo