From mboxrd@z Thu Jan 1 00:00:00 1970 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 C4E74374735; Fri, 31 Jul 2026 20:08:32 +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=1785528514; cv=none; b=Vmf/Apwnb68ERvglRV4BzJGSGHn+lw6dq5lz+iUGcNoHhS/W6hU6E5g4g3BySz/6Er8FV8CWp1iQUu1K7arrIjEciVZjH7rC7T+doxlREnOa7XQojpQ7BLOlKIuSHQnVWZ/dtbnp6CfSDUu/m0WSHGxX6rpWvO84ghHGnukEpok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785528514; c=relaxed/simple; bh=W87PURLsCUKnUlEcXXgZCM+qmQhX1yTxSPIEDk5nBD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EuaYO2sSs3dAEtl2+zbZnGT+62sWDuVeu5fq9w0mwJyrlqb6342SDw8oHBfvfKCquYc20Yl1m4VSuOm/PzMbJw/2S6IUdUJ3YwI5Z8RtzvSVhyVH1aJbAR5q2Z9rLDoX6YEX/3Jvfp+UfWgx00g51+FiWLu6dfRS6BTrJB2Tchk= 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=j/mFcgrg; 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="j/mFcgrg" 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=57pqVUBnNmX4cL7er9o4/zfu8e545pjnuaBSHsFeFDE=; b=j/mFcgrgk96/N4pP6VvSdeZMQl 2NyqLTCYAvKds2nk+fOZ1sx5/jOUoZqeZ4oFVXHhL+THSwlCuWBONdUwzjwZ5j6Ilv+c/L4A7dFYD 8XE1T3t92jFrBs51qinTzRit/cPBv/S9L6dA5d/KHT9+yOj930ZOqV5lRRRoLiQCSnOU8QZ8ddlRW xm8EkHu2njpTD8UDptnBaQLU8b5VJj1jBrWwX/oouNcbQ9Ov4mYYnXtrVvBuIzN1kM1pzxGDNC3Ec ehsc02QYR9xiooaC+18izCsV+OzQLchs+7zfIQQBKFpIDkvK63kBXBmd0Wbu5zjhlXVoqMl9CWCaa XZWREUCw==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wptWV-00000002Pey-41Nx; Fri, 31 Jul 2026 20:08:04 +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, "Gregory Price (Meta)" Subject: [PATCH v8 01/15] memory-failure: Fix hardware poison check in unpoison_memory() again Date: Fri, 31 Jul 2026 21:07:46 +0100 Message-ID: <20260731200802.574821-2-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260731200802.574821-1-willy@infradead.org> References: <20260731200802.574821-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 Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Gregory Price (Meta) Reviewed-by: Miaohe Lin Reviewed-by: Jane Chu --- 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