From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33EFF2D9EFB for ; Fri, 31 Jul 2026 04:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785471686; cv=none; b=jMEpDYHOMzzfXlT+Uq7/KbMyz4+22M5u1c7DeWLDl8W7hmUeo2EVpqd2qPuexKVj/kdELr6xD/qERaBgj5ppkK6RCThdj9A3j1bSX5XEYxsFeoPlTNNFxDISM7+RpcUdKF/4jcjgbHeQkp8WRO0Ui75G+Xf7ZiWsnS3TFS2kRqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785471686; c=relaxed/simple; bh=c7rChpsB+5DYPdIZHlwvb2jD62nm1r5MJzx2SvoiIJ8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dj1WGw9fKkcaS8smuFvFv1NBvrJwg3Bi8XgLHLGgXDnwv/EH7rwj3SBoGJ722G+Za/Hs58Mv7RZA5gA9J9Xn/X0Y1eG2JEgHj/904J2rb4/gqMmGWUZUHnTT4jelMHAzeVp0ezzXgvxrhoawNkDB5sM6q1p4+Vpjk7y7lUwBR00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=gKb4AXwL; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="gKb4AXwL" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54613204C; Thu, 30 Jul 2026 21:21:19 -0700 (PDT) Received: from localhost (a085714.arm.com [10.164.19.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B20183F86F; Thu, 30 Jul 2026 21:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1785471683; bh=c7rChpsB+5DYPdIZHlwvb2jD62nm1r5MJzx2SvoiIJ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gKb4AXwLblePR65NS8GYJhZwOxdxoeOOyAKRuEM0VhsIllPjQpzKZg+IwxfU+pe8t vFdzDHPVaf6u2tR3paWmnb57FefddON2pR+AiwF6a3AZQpsyTNTBK1ueoRYCEZSLdY S2MKK3viD1MUm9CZh4/uNbRJymouQ/f/r8n9ou2c= Date: Fri, 31 Jul 2026 09:51:19 +0530 From: Anshuman Khandual To: Dev Jain Cc: akpm@linux-foundation.org, david@kernel.org, ljs@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 Subject: Re: [PATCH v4 1/5] mm/rmap: convert page -> folio for hwpoison checks Message-ID: References: <20260730094559.418003-1-dev.jain@arm.com> <20260730094559.418003-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: <20260730094559.418003-2-dev.jain@arm.com> On Thu, Jul 30, 2026 at 09:45:52AM +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_*. > > Reviewed-by: Lorenzo Stoakes (ARM) > Acked-by: David Hildenbrand (Arm) > Signed-off-by: Dev Jain Reviewed-by: Anshuman Khandual > --- > mm/rmap.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index e854679553b9..77be9fcffa99 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,8 @@ 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)) { > + /* unmap_poisoned_folio() only refs order-0 or hugetlb folios */ > + 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 >