From patchwork Tue Jan 21 04:18:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13945639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA123C02182 for ; Tue, 21 Jan 2025 04:19:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B12B26B007B; Mon, 20 Jan 2025 23:19:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A99BA6B0082; Mon, 20 Jan 2025 23:19:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 913C16B0083; Mon, 20 Jan 2025 23:19:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6A8086B007B for ; Mon, 20 Jan 2025 23:19:25 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CC9AAAF499 for ; Tue, 21 Jan 2025 04:19:24 +0000 (UTC) X-FDA: 83030154648.09.CFA177F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 613AE40004 for ; Tue, 21 Jan 2025 04:19:22 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oDy7lGfi; spf=pass (imf17.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737433163; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=9HM1nA931kHrw3m9SclaY3HXr64myM0TA+bCFRYgF6A=; b=3a5uTVuRsaSEmg/LBqPVL44uvbvFeG1inuW7SXCHSueTxkLNrFalSozyrJLA0z95g/WayR hS+p2WPqCwasfgnwnDBsRdqOAIU80swFE0cj7xKelc9RuzNSFzAF846nsvJpm01/tgxPu1 gAWBmoc5AB0NWjYfRzHEGSuAKnCHUmw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oDy7lGfi; spf=pass (imf17.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737433163; a=rsa-sha256; cv=none; b=DSpgFg2rgDmcXoSV2SijXx+LEUD/Bpw3G91VcaEwhKEcd7TMUR+JTGL/oaLgwfiUi9wu3k IHJDQsOHK+uQYZYEJNsqtGdT1fG/z1CZrUWG7mSH8hir7u0hQWsRui/TAD2QyA91h0iPNP zRoxR1st2Qo8BfXtyq6FnqFQPsYpx/k= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50KGMvNH024767; Tue, 21 Jan 2025 04:19:05 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-2023-11-20; bh=9HM1nA931kHrw3m9SclaY3HXr64my M0TA+bCFRYgF6A=; b=oDy7lGfiAYrNO3zs6nsiGG8c+4YUokIH9dg4V224GP4zh d2JerNGJ5P7dOsQX8FwQK6D2UspuWb1wuhBGKTp51YJ72e5i60NXh0ChNnnfsU0P k0ZuvZXIBOuHwX3X527bTgMXJaL3aRSow1noBTNSV4dDbMtfOgGYnUSRlcHAaWEW QI14nf8owh1d6co21wgqAZ5JolhTYPvssAfsLqS4ik9kfJGFUndqoKFRpiwYFl1Z 9K106IwCBC4zdSUeN99pPaNpY+r4YEChgV2IBPI8Wn5+TykDSmfkmuox34q0vv41 jgNM2VuVrHPSi8DYhVLQ1irPnzbJK+tl9zvM5ZJhw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4485q54p9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jan 2025 04:19:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50L3VOaB029518; Tue, 21 Jan 2025 04:19:04 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4491fh8x8p-1; Tue, 21 Jan 2025 04:19:04 +0000 From: Jane Chu To: akpm@linux-foundation.org, willy@infradead.org, linmiaohe@huawei.com, kirill.shutemov@linux.intel.com, hughd@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: make page_mapped_in_vma() hugetlb walk aware Date: Mon, 20 Jan 2025 21:18:49 -0700 Message-Id: <20250121041849.3393237-1-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-21_02,2025-01-20_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501210033 X-Proofpoint-GUID: 4L0YNqVH6rUM6CM6SAt0YM0Xn3C7wwat X-Proofpoint-ORIG-GUID: 4L0YNqVH6rUM6CM6SAt0YM0Xn3C7wwat X-Rspamd-Queue-Id: 613AE40004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: iw8kzt9oy5nzpd3g1ctr81qbrkjunw5y X-HE-Tag: 1737433162-972673 X-HE-Meta: U2FsdGVkX195LJywtybfJ0G4NTfj+yGrzl1dBaPJGO8Aspxgy5sX9yRZ7/PsTEwueV9QKifmu+xd+ZHud1TVpCdk0CrEf0+tylSI7wmvucx6fZsYaddLNQ4LfLypBBqstBuFv2CCWkkZFn9g2IR+BZLSsZirjqJ5VF79rsgtdX/rMIqsPlkl9qGqsQQXUAsv59szVzUDwAwe2ZJNXm4xcbhFLT2beWcq6k/3C7QgkBss226oHV96qjdaZvALMswwSqJWfXK/vgg8M4inWfIMla+hIOG6Hy/mm+k1nksgw5ErDHBoMaNoRq7TXcDbQuu1SZHOvTCesg/btZcr+zv915xZMlXk6Tsl5/nG4qRYOll/DoCV2Sf9Y7Zf2LR9SI7cnj8i0qtDV50cFEwzmO/jDHkKb/ocBdblCJtXJA+iXPTAZPU6mTEjdjRAeLDa6w6lL/mPWH/DypghBXfwC72uxUgB2K4peXqIQ0vczJptbvHYAo3d9PiagCVqzWJRBTvI1mOEe7n+VyTrNmQrgbKfV3tDcltuAzPXSHJYS96v/hu2pjCiuyBhQX2eUTuLAGYK39AQj+1BYJPOs/i5tnzUeFX+x00jQhUwUiCxG5WOjQZ0/Klb1vcUF2QQ4YtPZp0iKy6sEHxNJbi88Tk6vmTZtbHDnb2v3iDjQ7iNq1HErKCp5FOYLlce96Z4neaZqAvno/keX0uqFpM+FPgXTc+ywZm0+BFvFobHRN1eVLlWI4xBUX3/Kq7uv8j+FM3L2S7Xc8zBj1WVHY07Aarq+zng5xOQcEvFM8g02uGa2XCCs76L07UlKGcg4Lyc50odS7Lw5Jxm1yPjra+R6kIknM4Q1YgSD7MVS3yKfjXaPzxbscSPPqKRlWq9wq5tAxCFL19JLBqmIxAZ8LCFG+L63jQOidFIYTPKXRYAjUCZ4ofL6p2elqkjSPyBn4rSB6okBZmj7y56cR7z5Jn2+NTM5aJ MllLkREV 7sTYtF/4HVpCkNCurrGL7WtTk2XLTLNQW8MnYEUbJRzRcKGUmStBt5mTJSBmrCkCjLjpDCdoYimgmXTavKVJ1gNuVU5hGP3aftGd1br5bQYHaLiosJIEhWJO4EmIpGBa3bnIzopnzwbZUrcmgOr+unAInAKYyMljewTxVm0WMENm9HhUgAZNUIYs/4b/pRapaE1G4edLVSGUKWgYSLh9QypOcrCtViJduLkJn38ifdtc0IY30IH3RgBM9Zvk2C+Ch5Mpgp6BrrUtRboWzMlzFNeuVAhuDhK2hToju X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When a process consumes a UE in a page, the memory failure handler attempts to collect information for a potential SIGBUS. If the page is an anonymous page, page_mapped_in_vma(page, vma) is invoked in order to 1. retrieve the vaddr from the process' address space, 2. verify that the vaddr is indeed mapped to the poisoned page, where 'page' is the precise small page with UE. It's been observed that when injecting poison to a non-head subpage of an anonymous hugetlb page, no SIGBUS show up; while injecting to the head page produces a SIGBUS. The casue is that, though hugetlb_walk() returns a valid pmd entry (on x86), but check_pte() detects mismatch between the head page per the pmd and the input subpage. Thus the vaddr is considered not mapped to the subpage and the process is not collected for SIGBUS purpose. This is the calling stack collect_procs_anon page_mapped_in_vma page_vma_mapped_walk hugetlb_walk huge_pte_lock check_pte It seems that the most obvious place to fix the issue is by making page_mapped_in_vma() hugetlb walk aware. The precise subpage in the input is useful in providing PAGE_SIZE granularity vaddr. Signed-off-by: Jane Chu --- mm/page_vma_mapped.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 81839a9e74f1..bc036060cc68 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -342,15 +342,26 @@ unsigned long page_mapped_in_vma(const struct page *page, { const struct folio *folio = page_folio(page); struct page_vma_mapped_walk pvmw = { - .pfn = page_to_pfn(page), .nr_pages = 1, .vma = vma, .flags = PVMW_SYNC, }; + /* fine granularity address is always preferred */ pvmw.address = vma_address(vma, page_pgoff(folio, page), 1); if (pvmw.address == -EFAULT) goto out; + + /* + * Hugetlb doesn't support partial page-mapping, hugetlb_walk() + * simply assumes hugetlb pte, hence feed the headpage pfn for + * the walk and pte check. + */ + if (folio_test_hugetlb(folio)) + pvmw.pfn = folio_pfn(folio); + else + pvmw.pfn = page_to_pfn(page); + if (!page_vma_mapped_walk(&pvmw)) return -EFAULT; page_vma_mapped_walk_done(&pvmw);