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 42BA83D3CEE for ; Thu, 30 Jul 2026 09:46:22 +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=1785404783; cv=none; b=rOfoqax5ngVjJNATQBculK7YRMDqvjR9eGQLr/T4ahfCfkUzLBdz/TThPYZagU0nxhcDCPfaSsntlj9cL+JUAxaeojLuBtm+uiSJNIkKQO3CJhXLXh8mB7NmB3pEgd4PPnrbBKS00SFgHWiB1AY9wIN73rLQGpXdsP8zEkPL+3Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785404783; c=relaxed/simple; bh=uvhE/tFT7Ldq689DpjcwVfkSIZmSWyixS8rBTZRMflU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tcOwzNH11Fj/AsUG+apesLtz0IRr+jhy5a5PD05dnJ3O3+aLe1EUN1rhWVVn0yzahQIxJM+/ZYUTwKo4HJcLWQfqotWtud9HDZMTUUDsG5/vU2dmNF5cRyVQA5DI03jX+Lrql+YI9hCQ2MF8YqXIb9RMpcwxQcSPUwm4ViY1rag= 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=a8rlygMd; 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="a8rlygMd" 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 7C3241688; Thu, 30 Jul 2026 02:46:17 -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 4C0113F763; Thu, 30 Jul 2026 02:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1785404781; bh=uvhE/tFT7Ldq689DpjcwVfkSIZmSWyixS8rBTZRMflU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8rlygMdOo1mh6AIf2sT1e2i0T/CI+npPbtTQfKJyNeJatDW9LJB4vHRocMvy2+16 dKHdjeGuxDsBoJywpsA0aEnmZ1VdbVSAimGdHd25OpiYfJU+KcsgFAuLfQomAPYrAZ D0/yq0ujGZVHTvArQ8YtZNtoWf5dr2x5SRKxrMB0= 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 v4 1/5] mm/rmap: convert page -> folio for hwpoison checks Date: Thu, 30 Jul 2026 09:45:52 +0000 Message-ID: <20260730094559.418003-2-dev.jain@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260730094559.418003-1-dev.jain@arm.com> References: <20260730094559.418003-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_*. Reviewed-by: Lorenzo Stoakes (ARM) Acked-by: David Hildenbrand (Arm) Signed-off-by: Dev Jain --- 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