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 F2B5F371068 for ; Tue, 26 May 2026 06:37:03 +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=1779777425; cv=none; b=sKd/SrDWkamcZ/sUJ2dbbLo+rckhyc5woaqZ0kjVyjviZnJpTvFiIxAwn0G4Jric1WSj/Sf9tfrvj8PfQyqm/fuUFnOulQyCeQK0u3MDjqd3vIC+mC8IPprN8mWtT1ErgQ3JFmIaEcIP1ZoFiZAQsyIGwWGSWeaBO+CH7GXcwyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779777425; c=relaxed/simple; bh=Xa/9er1eUX/PuSAWKy037qgiAtOJ0rif1cB6o4Vp3s4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HyMJh35CQRM3I293pFwQjd5okwwsgsH7s75zs0BuLQkb2GIBxCe7/ZtgrCgcP84L+7EhBSbHCh34fYY8+9lZV48/8E4VqeK8I8OUK5ViZ5rlXRWhrdeRrvrG5SLYXmk7SJjk4xt/hJCuAgJYCZrRy466MEKE8anCTvyHuokE8hY= 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=n7cVM1vS; 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="n7cVM1vS" 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 51A3C16F3; Mon, 25 May 2026 23:36:58 -0700 (PDT) Received: from a080796.blr.arm.com (a080796.arm.com [10.164.21.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE4AC3F7D8; Mon, 25 May 2026 23:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779777423; bh=Xa/9er1eUX/PuSAWKy037qgiAtOJ0rif1cB6o4Vp3s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7cVM1vSlO49MbiHV/Xz81cr3twIDsXmkmVC0yeSEedBCIz4I0/6hsuZsDsH2lUaC Duy482BDdc9uS6iS9Ja2Xv8XlWvuX4PshenBqpYH1EuoOo0WadLbRLB5lmIz3rrHBC Aei6IwKbRCGjkgGaHzQhXAuXIoc8JCV+bfiKntMs= From: Dev Jain To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, chrisl@kernel.org, kasong@tencent.com, hughd@google.com, liam@infradead.org Cc: Dev Jain , riel@surriel.com, vbabka@kernel.org, harry@kernel.org, jannh@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, youngjun.park@lge.com, baolin.wang@linux.alibaba.com, pfalcato@suse.de, ryan.roberts@arm.com, anshuman.khandual@arm.com Subject: [PATCH v4 01/12] mm/rmap: convert page -> folio for hwpoison checks Date: Tue, 26 May 2026 12:06:24 +0530 Message-Id: <20260526063635.61721-2-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260526063635.61721-1-dev.jain@arm.com> References: <20260526063635.61721-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 If any page of a folio is poisoned, try_to_unmap() is called with the intent to remove any mappings pointing to any part of the folio. Therefore, an hwpoison check on a single page does not make sense (although everything works out because the memory-failure path sets hwpoison on the head page too). Convert these checks to check whether the folio has at least one hwpoisoned page. While at it, convert VM_BUG_* to VM_WARN_*. Signed-off-by: Dev Jain --- mm/rmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index fb3c351f8c458..430c91c8fe2ae 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2116,10 +2116,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_contain_hwpoisoned_page(folio), folio); /* * huge_pmd_unshare may unmap an entire PMD page. * There is no way of knowing exactly which PMDs may @@ -2198,7 +2199,7 @@ 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)) { + if (folio_contain_hwpoisoned_page(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.34.1