From nobody Sun Feb 8 09:12:48 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 2E4BE42049 for ; Fri, 19 Dec 2025 06:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766125743; cv=none; b=H16Lfyi02zKhxJQXk5a2gZSHyTWmjVsYHMMloDlgEtKST0NP7fbhh0PmDdRGkggL/LsU5dtBnDr5dJoxt2PgwgOOQI2ClD1v6+n9o4umuwXR/G5iGQI678iqRzN5SgXQSiBxY2WNu8Xe/G0VF/bJw/H9+CwyriVC6MCvGpfm/9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766125743; c=relaxed/simple; bh=bTKiW16e/F1zLOrxlI+OiAyrSXrxcSa1O4Qjid4FuOk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=qqAVj2OF6ipDwAt5v8B+9qu7cLGddbIJTb1rbrmkWK4PfHqJzk0Ee0g6sGSiEX/xgi6Az5SMa/bSN5FijOO1n3F/no85NkSOMxWCAkabQ8JEkfGxKpEw9jb1bAS8RMAeVbJuk43lDWZbdPUXLRosOUqbKf6hjVhecTGWdicnxBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=cFu1T7t0; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cFu1T7t0" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BJ3Ec192694735; Fri, 19 Dec 2025 06:28:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=corp-2025-04-25; bh=I6QrtPwtlqYhnAG5c9JpOVRkSlpde STls/VSNXrj580=; b=cFu1T7t0oEapEdpYUbK6tN3PDkBLfck8/2XxO8Ejsxw+N vhI6IOw4oejqjctteTymVA5pc9C2nM33e6l/UnGgunR+Lc3+U+c0ZH6pbmAbxzMu 4Izo2+mzxhJpF46ctNi11AvxOYeyKxcB6USYhEN3HV8zqlQUORDv8jjEGm/p1yp2 DlFn85lkxNt8ZkWCevfMXRqzJGSLmJG9aRUXw5kQTJWgBii95F0BQbCpgMot8sOi uJIjU7HYZprPY2JxqPOeZCZjjPzMZK/g1UJyYKuY3qZypxqFqw6K+TytI6o+GNA1 6WakfZWy03voPgy6a5Rbc4CQ34VeYf3vA634yatSA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4b4r290jan-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Dec 2025 06:28:31 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5BJ4pwKR023986; Fri, 19 Dec 2025 06:28:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4b4qtdrjy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Dec 2025 06:28:30 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5BJ6STqC022140; Fri, 19 Dec 2025 06:28:29 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4b4qtdrjwe-1; Fri, 19 Dec 2025 06:28:29 +0000 From: Jane Chu To: muchun.song@linux.dev, osalvador@suse.de, david@kernel.org, linmiaohe@huawei.com, jiaqiyan@google.com, william.roche@oracle.com, rientjes@google.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, Liam.Howlett@Oracle.com, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/memory-failure: teach kill_accessing_process to accept hugetlb tail page pfn Date: Thu, 18 Dec 2025 23:28:19 -0700 Message-ID: <20251219062819.2499399-1-jane.chu@oracle.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-19_02,2025-12-17_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2512120000 definitions=main-2512190052 X-Proofpoint-ORIG-GUID: 3gq8SPjeieSOd0fhM_CRtXdX1oBwAd-h X-Proofpoint-GUID: 3gq8SPjeieSOd0fhM_CRtXdX1oBwAd-h X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE5MDA1MSBTYWx0ZWRfX9Wq9wk/Hp6J0 hoZvLTkEiBAa2NKJmqWlPcildrr74IVPJbQTaFISIp8tURm0DZXAGSxLUOE7u6wiThisjYR1jN6 pVTzjwRuwp82sV0murtvwuUughyGAA1ZjDEODTUKTMlkheognJvCYLeB4e2/r8hiPT1cBn4wy75 yE5CbbmyazhjGvZu734FHOBrlMAO81lpqdDDmormQRv+tvZvt8pIIPGKhaVwCbMiaIMBXiesz/6 5DoFs75AHoehOGEzj14bZUIfzxRgqOH6kTuViCRBa5XmNFgQ83GUraYKWJ8aQVw/D2sq7beRm4B KamdFJh4oyFRRXFtFNK8VKl2FIbG5ZIv5dMxbBFEOnah8Zk+E0qymwhnqiArS2QPWQUvEpNWAkB 7Lwtd2zWCxSN1Z0qat+Dfdt/6r5NbsCYOyZ9T+cyCaJNDUh8EikObFVfvva/Csihs5AF/OCzerz +vSpCjuvLtvrORdVZjw== X-Authority-Analysis: v=2.4 cv=efkwvrEH c=1 sm=1 tr=0 ts=6944f08f b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=JfrnYn6hAAAA:8 a=yPCof4ZbAAAA:8 a=1XWaLZrsAAAA:8 a=f-Xke4JHVjhQjhv6I2sA:9 a=1CNFftbPRP8L7MoqJWF3:22 Content-Type: text/plain; charset="utf-8" When a hugetlb folio is being poisoned again, try_memory_failure_hugetlb() passed head pfn to kill_accessing_process(), that is not right. The precise pfn of the poisoned page should be used in order to determine the precise vaddr as the SIGBUS payload. This issue has already been taken care of in the normal path, that is, hwpoison_user_mappings(), see [1][2]. Further more, for [3] to work correctly in the hugetlb repoisoning case, it's essential to inform VM the precise poisoned page, not the head page. [1] https://lkml.kernel.org/r/20231218135837.3310403-1-willy@infradead.org [2] https://lkml.kernel.org/r/20250224211445.2663312-1-jane.chu@oracle.com [3] https://lore.kernel.org/lkml/20251116013223.1557158-1-jiaqiyan@google.c= om/ Cc: Signed-off-by: Jane Chu Reviewed-by: Liam R. Howlett --- mm/memory-failure.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 3edebb0cda30..c9d87811b1ea 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -681,9 +681,11 @@ static void set_to_kill(struct to_kill *tk, unsigned l= ong addr, short shift) } =20 static int check_hwpoisoned_entry(pte_t pte, unsigned long addr, short shi= ft, - unsigned long poisoned_pfn, struct to_kill *tk) + unsigned long poisoned_pfn, struct to_kill *tk, + int pte_nr) { unsigned long pfn =3D 0; + unsigned long hwpoison_vaddr; =20 if (pte_present(pte)) { pfn =3D pte_pfn(pte); @@ -694,10 +696,11 @@ static int check_hwpoisoned_entry(pte_t pte, unsigned= long addr, short shift, pfn =3D swp_offset_pfn(swp); } =20 - if (!pfn || pfn !=3D poisoned_pfn) + if (!pfn || (pfn > poisoned_pfn || (pfn + pte_nr - 1) < poisoned_pfn)) return 0; =20 - set_to_kill(tk, addr, shift); + hwpoison_vaddr =3D addr + ((poisoned_pfn - pfn) << PAGE_SHIFT); + set_to_kill(tk, hwpoison_vaddr, shift); return 1; } =20 @@ -749,7 +752,7 @@ static int hwpoison_pte_range(pmd_t *pmdp, unsigned lon= g addr, =20 for (; addr !=3D end; ptep++, addr +=3D PAGE_SIZE) { ret =3D check_hwpoisoned_entry(ptep_get(ptep), addr, PAGE_SHIFT, - hwp->pfn, &hwp->tk); + hwp->pfn, &hwp->tk, 1); if (ret =3D=3D 1) break; } @@ -772,8 +775,8 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned= long hmask, =20 ptl =3D huge_pte_lock(h, walk->mm, ptep); pte =3D huge_ptep_get(walk->mm, addr, ptep); - ret =3D check_hwpoisoned_entry(pte, addr, huge_page_shift(h), - hwp->pfn, &hwp->tk); + ret =3D check_hwpoisoned_entry(pte, addr, huge_page_shift(h), hwp->pfn, + &hwp->tk, pages_per_huge_page(h)); spin_unlock(ptl); return ret; } @@ -2023,10 +2026,8 @@ static int try_memory_failure_hugetlb(unsigned long = pfn, int flags, int *hugetlb *hugetlb =3D 0; return 0; } else if (res =3D=3D -EHWPOISON) { - if (flags & MF_ACTION_REQUIRED) { - folio =3D page_folio(p); - res =3D kill_accessing_process(current, folio_pfn(folio), flags); - } + if (flags & MF_ACTION_REQUIRED) + res =3D kill_accessing_process(current, pfn, flags); action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED); return res; } else if (res =3D=3D -EBUSY) { @@ -2037,6 +2038,7 @@ static int try_memory_failure_hugetlb(unsigned long p= fn, int flags, int *hugetlb return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); } =20 + folio =3D page_folio(p); folio_lock(folio); =20 --=20 2.43.5