Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 43C9442FCA9; Mon, 27 Jul 2026 18:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785176027; cv=none; b=HXPkljebPR1yrhlpAjbny6pwi0pdsZGwuom89vk9VXoRIbSHK89DovdMICNDR9giS5B9LTt4UIq1zHVzxAprkPoybOZapr4zfqAZTUlIfSdT8q1veTHPHYEMjCTpdc6+3aBA6iWJpO5m+whyjYPCAVTNRzZR9tmSeMFiimUnwz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785176027; c=relaxed/simple; bh=M2KSLYYNbLF9loGD0Sq3/5LKFq762/1KseQ7d6xoicU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PjvHVjPjaeH2BpIOk0FJdFxE7UMTeL+TM0MHDn9GWnyL8pt0f9e8KGg03/sAhzJtxInnfalWbUZ0JLNF4DHaRKcd8J4HYtYdhAbRR16xqVh7sKPIamlwbTWFiNl1J5CUplD//73ZfjniC1SMZdo/EJixWUTyg7FRmGpolHuvG1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=BqNC1Mb6; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BqNC1Mb6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=vE4+w4YDu9n7GIhNK4fpCQW3h/DoqyUfQ4ETqQ3wP4Q=; b=BqNC1Mb6CX3IpIk1sdjIoEYVIC gbFGrRyiDq4/7YjpjwUNc+kcaXHP2BqjV/2bdZ7A9yLz26DRiE9fuoYdtLmNZvyPSagIsejqUraoP 2GoLp7fnEgRcdQqw6M99mi+3bZsY6Onxv2wH4W2+nr2s8iiJfIFcRIBJs9VfHFv8rhEOlLF+fvRPc THehUdMHBj46N/C1pBEp5xPACz2wN6ZhpDEyqiiMCBXTypnvqosZ3nG8L7HVo/nt4ltX8tkQqu8ti ScZg2c0fcAKg+1MMiz4Pguecc9F08lHEa/Hl6uerEc+TF6x6fKqoV0+iXk5rTkRKYMvVGvmt10qxY Eba/mTcw==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1woPp9-0000000BD7O-3fkE; Mon, 27 Jul 2026 18:13:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Jane Chu , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Muchun Song , Oscar Salvador , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Jan Kara , linux-fsdevel@vger.kernel.org, Christian Brauner , Jiaqi Yan , stable@vger.kernel.org, Naoya Horiguchi Subject: [PATCH v6 01/12] memory-failure: Fix hardware poison check in unpoison_memory() again Date: Mon, 27 Jul 2026 19:12:57 +0100 Message-ID: <20260727181310.2671972-2-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260727181310.2671972-1-willy@infradead.org> References: <20260727181310.2671972-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The earlier patch (6c54312f9689) that attempted to fix unpoison_memory() was incorrect for hugetlb folios. Before a6fddef49eef, we checked the head page for poison (which was correct for hugetlb and incorrect for THP). We are currently incapable of unpoisoning pages (other than the first page) in a hugetlb folio. Use is_page_hwpoison() which handles hugetlb pages sufficiently well for this purpose. This is racy as we don't have a reference on the folio at this point, but fixing that properly requires deeper surgery and this is a CAP_SYS_ADMIN path only so this will do for the moment and can be easily backported. It's no worse than the situation before a6fddef49eef. The other bug in a6fddef49eef is that we currently clear the HWPoison flag on the precise page, which is wrong for hugetlb. Fix that too. Fixes: a6fddef49eef ("mm/memory-failure: convert unpoison_memory() to folios") Cc: stable@vger.kernel.org Cc: Naoya Horiguchi Cc: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 51508a55c405..944e6e1d4971 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2695,8 +2695,8 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (!PageHWPoison(p)) { - unpoison_pr_info("%#lx: page was already unpoisoned\n", + if (!is_page_hwpoison(p)) { + unpoison_pr_info("%#lx: page is not poisoned\n", pfn, &unpoison_rs); goto unlock_mutex; } @@ -2748,6 +2748,7 @@ int unpoison_memory(unsigned long pfn) folio_put(folio); goto unlock_mutex; } + p = &folio->page; } folio_put(folio); -- 2.47.3