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 7F53C35F199 for ; Mon, 13 Jul 2026 05:01:10 +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=1783918872; cv=none; b=axbTL27r2OTFpNl7lLXf2/chmnfuDeYFzDJk13bPXv+MMwkGEXUKDQTY9Mq6iLoYgH1EMHXI85qH1G4Shrg7dctX3AQoLko8MSzImOKw6A9XNcCYh0X/idRJcBEArI9j3SrfZlCTNtMtP+XuJncHbFXZssde5DQLYvZFYPGNcjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783918872; c=relaxed/simple; bh=f9Tys1Cvm6yJflSHdH0xqAExQOs6Nr0MHrCE80JqbDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AhHxXjXeH3K4i5V/B8RXq9HvJqsBFW4/Ecrpm5CGcMqLzloAx/7RliTrQP/b9GD3It0uCiHA78ls59vJWy3Q0INRv3/qVEua368bkB3f9TrodXc7FrBkKRRZTnqQBeCHTSyZli/7pyKyZiedhsMh5E5zyYuEhTQFfGXUmFxfELA= 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=IJAmj6Or; 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="IJAmj6Or" 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 855A1497; Sun, 12 Jul 2026 22:01:05 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-01.blr.arm.com (cesw-amp-gbt-1s-m12830-01.blr.arm.com [10.164.195.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 85BE03F93E; Sun, 12 Jul 2026 22:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783918869; bh=f9Tys1Cvm6yJflSHdH0xqAExQOs6Nr0MHrCE80JqbDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IJAmj6OreHuA8GCVfOWOXpQ+RGDdi9qE1KRh3Oz/kBGduz6kKMYeTYffG8IxuCqEf NjBd2C1fNlzbeFWFMxY4kVhB6a5ESW7piA6AG5gkuv5/wbRaJyHwUxC88+bMCSwLaM zBGptXblrb5E7gQvPqfkkCIYAdg9HpciPjjAklhA= From: Dev Jain To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, muchun.song@linux.dev, osalvador@suse.de Cc: Dev Jain , 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: [PATCH v3 1/5] mm/rmap: convert page -> folio for hwpoison checks Date: Mon, 13 Jul 2026 05:00:44 +0000 Message-ID: <20260713050050.1017741-2-dev.jain@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260713050050.1017741-1-dev.jain@arm.com> References: <20260713050050.1017741-1-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-Transfer-Encoding: 8bit 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 --- 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); /* * 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)) { 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