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 F079341A4EC for ; Fri, 24 Jul 2026 09:20:45 +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=1784884856; cv=none; b=Fkob27w9nOgvDOvie4GiR9XgkNTA9mNfgsg/ngjf+fdcV/ZE/XGYpNibelUBCFJgdu2nylC17yt/UPBH2rgW44h5eHTxGN40RpnlvLcMgU/qz4iPo2Ihavab4LvmQiyRnLXg7gnP5X8yvXZdFcbbVzVnDdmtQ00Ejc3n3+Vgbfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784884856; c=relaxed/simple; bh=qQ/gJAGOtB75xKS5EuoGyHqzK1hhBGh4qxrrQ3S+jHY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RCZ+vOh3+OS0o5vgf2yMato13nQTGVAz5l018UX+U7kv+euQTja7n73SXDgSBDzPhoEn6snhxyrADaqHj1wv1Pf2s2O78ujJy6+zIVTpjKwE/D/3IqQvlB9XMy4v4t9JBhCtYXEyOsfYEfoOv2eagaTfij6cM54w/AKMAKZV/kE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lwL9r7Hh; 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="lwL9r7Hh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E43A1F000E9; Fri, 24 Jul 2026 09:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784884839; bh=sK+co/kJmG6YP8VnMhZtZK+n9ApW8e/do+0Igtss8NY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=lwL9r7Hh7relOof30oLbXNAQGciP0LI00Mjhi1C6Yz+HE94rQfdQ6sui104q6tvyA 8/iNYuHx5QsBpvHGRjb2xpPUb7DNBCMkSkcLbQwRSgAs4r1mDN8HpQsduhO0wxRQOB QPZDQWIj2jkjYkVfI8IKID5O5/yr+LDE0RgYfyzqpI+hkl7LFZW8blwU19kUBBW7db 00MfvbTPlK8tZZ8JmPHQeaX1lqfRjTNrVKT8V1MNHB4lu/p6xghOBgnsSLxXQZyEQE 5lsdI6kINwdr55RvMd2VGFcXMAcbeB5mtGaUPbJ8Rt1uAxbnWajJL2y6dzmFCZWCcG rLPim2PrhWj6w== Date: Fri, 24 Jul 2026 10:20:22 +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 v3 1/5] mm/rmap: convert page -> folio for hwpoison checks Message-ID: References: <20260713050050.1017741-1-dev.jain@arm.com> <20260713050050.1017741-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: <20260713050050.1017741-2-dev.jain@arm.com> On Mon, Jul 13, 2026 at 05:00:44AM +0000, Dev Jain wrote: > try_to_unmap() receives hugetlb folios only from the hwpoison path. > 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 Oops reviewed v2 by mistake. This 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 26166a6b8cb9b..2b74668f356d6 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); Thanks for converting this also! > /* > * 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. > + */ > + if (folio_test_hwpoison(folio) && (flags & TTU_HWPOISON)) { As per v2 discussion, I feel this could be tightened up, maybe something like: /* unmap_poisoned_folio() only refs order-0 or hugetlb folios */ > 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