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 F06943F7A8C for ; Tue, 7 Jul 2026 12:11:49 +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=1783426311; cv=none; b=h9czov/q8uhdyD54I5EXHnb8yZpAUb3zmShpUuN5TaG7QWm1Z6XTfvhPp1mtkLvn6VYibHYgviGqVL9teB9XV6HoHXw1vdPw0WNmF7uVS8tueAyXi+KgauX8VEpD6YJD8jnMkB35xi7nbrduHI4HEZrsPKKFPQaOGof+hCvOa1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783426311; c=relaxed/simple; bh=sG8kuXUpuA3bXsCULrMf6aBnRcFdA5YshgzZNs3gKMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sx6ch2ZXFAAyTF3Y9bZ/JqUJqWVDuWA9aK6QQIaJwTq8LDrf6BOOp76XE7lRJQ5AU4+dO3mGQWs+fGdrq44rktPyhrit45QpcKJQtx2kaGRVw4/vFUmovaHBs2ofiV+y2yhKfqJx9AAmhBfDr8tJtye8lN9h+tzMT/Af7l/ZUh0= 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=RDDfbMhK; 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="RDDfbMhK" 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 D1FDB1A2D; Tue, 7 Jul 2026 05:11:44 -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 EB5053F7B4; Tue, 7 Jul 2026 05:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783426309; bh=sG8kuXUpuA3bXsCULrMf6aBnRcFdA5YshgzZNs3gKMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RDDfbMhKhCUcNWpBtfuzJuvj/2D0+DwL0pAugw5qs9KqoeI5Z2YF95UOostcjvRsD sLgqwtT9pcyCQptuyXi4R2oTkDLwMkjT2NqkJFAhmlbtHpQhHCMUx5j39fFdGfNx1z ypyQhW72HI/InrjqEE8zpYQGMDlsh09A5M7H2yn4= 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 1/5] mm/rmap: convert page -> folio for hwpoison checks Date: Tue, 7 Jul 2026 12:11:19 +0000 Message-ID: <20260707121128.373192-2-dev.jain@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260707121128.373192-1-dev.jain@arm.com> References: <20260707121128.373192-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_*. 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 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. + */ + 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