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 986EC3B2FF9 for ; Fri, 24 Jul 2026 07:48:23 +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=1784879305; cv=none; b=QDbZ0PU/rqy6A3lUkNcc8NI2hreO5UfO9i83kWJBPtFtyscvZUvIqt/tEfyIojoLuCZ364RZRqN2mjjDxftYU3nEoFbexC9Zp97HdgwdOjkAyTMZgE7deECWv/9cvMnCuTNYv0qEqiMaVRtyhvpN+J7AkSOVMcC+NxfUZaWK8Wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784879305; c=relaxed/simple; bh=qGKiE8pgr1xnwQnpP0vfShpeQTP4GBz2y88Uv6pwi8c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f8nENeWmDGx00QTuMmsuTshLRPxBn17FHI/NE9IST97gy5zDJ0NRPiNmO3e3GUScVql9OFcc2EtvEat081cSG1eykznWamn4XdPjfLJqEcinXn0jQ+z+td9T6UTlftk+TZ9Z2C4zJ9MQTC4sG8tVuE46+3DX9s6yXr8CymZ4D7M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SOaXFBuR; 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="SOaXFBuR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B6D1F000E9; Fri, 24 Jul 2026 07:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784879303; bh=bO3E9Wlp8V9BbDWot4WwlaXnfOfYvMBhEhsCHrbT5DU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=SOaXFBuRKELMe8KH64C7KST7n8Oh9frVdPW5uggd8hhm9ZcUMhgc0VxjKYDYyntAR RgpRZm8msALLb35JkjbKvh6OQDWgDrgi9rVCTyy0dbFRLVWdQeKE5GnI6YwpUWYXFH 2vcSCKYQdqbw/yISMhIszPpPx0PxpULTXPc683yh3hwXurIMEyStUlCTTPN0/HZZxk YiyxMeve7rv8BqbMoY6PxtQEG7rHICXKlA6gsJDDsxjr2kITVLSJBwk5ZeHJHvKEiu tIjnOeCN/B31GCf0HayMEfBAXgVhiKspcV0CXc3TGSKzS4J8u4Ju5+oeYp/7wQbxnk 14DFgIcMW8FLA== Date: Fri, 24 Jul 2026 08:48:05 +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: On Fri, Jul 24, 2026 at 10:35:34AM +0530, Dev Jain wrote: > > > On 23/07/26 10:45 pm, Lorenzo Stoakes (ARM) wrote: > > 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? :) > > I had posted a v3 here: > https://lore.kernel.org/all/20260713050050.1017741-1-dev.jain@arm.com/ Oh sorry, missed that one! Will take a look. > > In that I had fixed this comment to drop "or hugetlb folios ..." . But I would > still like to retain the "only expect small folios" comment, it adds cognitive > load when I am reading try_to_unmap_one and then have to go read hwpoison code > to figure that large folios would be split before coming here. Yeah fair point. I wonder if we could rephrase it a bit, 'small folios' feels a bit ambigious. But I'll look at v3 and comment there! > > > > > >> + 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 > Cheers, Lorenzo