From patchwork Mon Jun 24 22:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Bland X-Patchwork-Id: 13710191 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 560E9C2BD09 for ; Mon, 24 Jun 2024 22:11:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB33B6B036F; Mon, 24 Jun 2024 18:11:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D61C06B0370; Mon, 24 Jun 2024 18:11:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2A2E6B0373; Mon, 24 Jun 2024 18:11:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9FE666B036F for ; Mon, 24 Jun 2024 18:11:31 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 469BEA3DAC for ; Mon, 24 Jun 2024 22:11:31 +0000 (UTC) X-FDA: 82267179582.03.FAB5A58 Received: from mx0b-00823401.pphosted.com (mx0b-00823401.pphosted.com [148.163.152.46]) by imf21.hostedemail.com (Postfix) with ESMTP id 5E75C1C0016 for ; Mon, 24 Jun 2024 22:11:29 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=zT6JBiLG; dmarc=pass (policy=none) header.from=motorola.com; spf=pass (imf21.hostedemail.com: domain of mbland@motorola.com designates 148.163.152.46 as permitted sender) smtp.mailfrom=mbland@motorola.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719267078; a=rsa-sha256; cv=none; b=TBy9RB6Xg/8Sg6d9OsT5lxKCcGXhQaKk6VFdlMRGegWIzGTIlDs/yVDJzvJPBLHZfVXRD0 tNhjoMP1fyP72O4QW0GSXiLFjyooGAZ/BNvFay6bm/wGPNaXbvWIpMsRDgTZ/3/wfvXRLF Kcc1zdhnwCb4OrsB1bjBl9jrRug8j9A= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=zT6JBiLG; dmarc=pass (policy=none) header.from=motorola.com; spf=pass (imf21.hostedemail.com: domain of mbland@motorola.com designates 148.163.152.46 as permitted sender) smtp.mailfrom=mbland@motorola.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719267078; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UFM48GN3j3TGnx2m6Bd7A0f60Mbw6SruFuO0J8syXfM=; b=ToDt/IjNlEZgO1DApQSqXQaF3lxY4v1XS589sYoxLxLZAexESqUl7XXUZme5/KFmt2mMMJ /R3gzryUiLd01wjOBpfk94G6i+yglUYWLPiQ9AnGPnkVTDyLKeFIrHuk1hZEKJkmLzlWNy bsRy+pOBjhw+9sFpPIfj3Ih97/aa98M= Received: from pps.filterd (m0355090.ppops.net [127.0.0.1]) by m0355090.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 45OEviBT032476; Mon, 24 Jun 2024 22:11:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=DKIM202306; bh=UFM48GN3j3TGnx2m6Bd7A0f 60Mbw6SruFuO0J8syXfM=; b=zT6JBiLGKlW7OsPoAxDU7armuhbSVL4zAti3VIz vcbbu4uTtdTgdZuhjEbC6MWV6AabXIk2EHJtQqHZndEl21H0ASABOLFoJoUnVR+7 XBtU2HQpJh4m0Y9DZpLHM/D103NqBvBDEcMs821PsalH2NBDeaSlHuOebrqxv/tQ sYSoUuaDH0Qyj4dpGx5aR6QU+122CzuP4PHvWRoXN9/06km3nwekdAC0+Nf63+jx EECjS3rEFp23fORSgPl55HXvDd9E32Qu5j8TvjZC7KBfiEmwMda8zbMSMUQH/7HB XgdshYxnT+ZUQ6CsPhoptHDCHJPsbMHO0xVsHw+O4WFfD1w== Received: from va32lpfpp04.lenovo.com ([104.232.228.24]) by m0355090.ppops.net (PPS) with ESMTPS id 3yx9xrk9yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2024 22:11:14 +0000 (GMT) Received: from ilclmmrp01.lenovo.com (ilclmmrp01.mot.com [100.65.83.165]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by va32lpfpp04.lenovo.com (Postfix) with ESMTPS id 4W7McK3jM7zj9hH; Mon, 24 Jun 2024 22:11:13 +0000 (UTC) Received: from ilclasset02 (ilclasset02.mot.com [100.64.49.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mbland) by ilclmmrp01.lenovo.com (Postfix) with ESMTPSA id 4W7McK1zL8z3nd8L; Mon, 24 Jun 2024 22:11:13 +0000 (UTC) Date: Mon, 24 Jun 2024 17:11:12 -0500 From: Maxwell Bland To: linux-mm@kvack.org Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Ard Biesheuvel , Mark Rutland , Christophe Leroy , Maxwell Bland , Alexandre Ghiti , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/6] mm: add ARCH_SUPPORTS_NON_LEAF_PTDUMP Message-ID: References: <2bcb3htsjhepxdybpw2bwot2jnuezl3p5mnj5rhjwgitlsufe7@xzhkyntridw3> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2bcb3htsjhepxdybpw2bwot2jnuezl3p5mnj5rhjwgitlsufe7@xzhkyntridw3> X-Proofpoint-ORIG-GUID: aFZWZNnXyYrEtj8CTtxn_sgc6qmXaZgc X-Proofpoint-GUID: aFZWZNnXyYrEtj8CTtxn_sgc6qmXaZgc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-24_19,2024-06-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=615 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406240177 X-Rspamd-Queue-Id: 5E75C1C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 116cbfj37gqhisiwigtbwmdbb16s8mkp X-HE-Tag: 1719267089-402494 X-HE-Meta: U2FsdGVkX1/TFuYZAiaRGJ1NVEnosdPDhbUE4uLmoOOCoIHjrOy22fr0foTAbwN4aw0SeWPUaHDSXvYypOpUQNgVt7x4T/bLbW8UwKtgySMLKYgWkY3ogr4O/7TA281cUjI8UKyY1UM76hk0I7DN1y3h3OLaUxNQ2lW5fGs26V4JZOtqNlE5lQNOjgnDFO4gv5K0lPyjabjVi9hZk6SN3Ab9rPvtbTkS2My7zGSZUQM8fGhy8lo3/CPuIPlvQFmOuh77DH6BVMMg0YubzugEqrYsPIargMaOn3emMtcu4RedQr0E+l+3QSLcCnqK6L/+EuaL1OlEn9WLGyFp7zVGnqYYF0MTOArqFbkELkFIB0ZGXgc9NGR8M9gyP7o3e8lRkG1GT69pPWJ3Hx65yX0EB5gCbFz+vbgCzjF7GsIwHj9MgohPDE75wHwyw1f4JQ//BOXLlsTcZTaAJTn/0Nk54KCiE5q+bCd2RYdSQuOCAoyr0TPMRQTwJCSA7WVHC4uNXlqJRhn7NHOyBFnrWtPSTbPdN1sLKcx+2y2Hy/gVx353ffWeXiPs9RFSdUGsNiRFxPATC/NR47FcJ0N9PfVBFCc/6FBvCc8PHKjkW+3YTwXLnGCF7MciIDOyaeyB3xlsuuFvT+mOA3+xBs3iBjfWHKmOOu15lAGbX5uutQVVsLzUZ6vgAaVN1LD5JrAfpmnXcZx9dYSM7RF5iqIvQE+7xehpyTxhMRPsYhJy+WNZzXtiMGPBFI0NOgaWcCx4xoFkLwzGskFcrz3bPIWANSXAcPBv+ssMFtKIfKwIKpCjdR/poOefM5SUZd04ejiuQKLH0LVf5ZSUTE9ykmUe7hL7bRhJMrFBuZ8/Tf9v26e83sFhTtrDS2vi+OphrqIN9UFivqt8taRm2qcRI5UeaXLsJwWe36RsBL8qoNUPH7sw9rkHF0zKW+gSwoRYCC0oSP2zZa8jfXNUsGKd5yj3DWH WYoGKvXb 3PmCflQUANEXpxm4E/LKymGvyflLCqtwZCWvuDHKrhy6Ugah5+As2xpAHvPQtRy7HDRdvP3YZx3IQRC+LmKIMND7T8yc9/OYiqL8nWizPiysm5r9e4jdOzt4DeI9a6a4SqnxxjeVnpPD+NOuLlDXCKTh7cdBeFxiYv8wPbV8V/9Bs6K0WBPhkW68donXM5UumFOyd2BrUxFgDQIreLhEcEXT0ycdSU6y5w1lQ3ekkArVytLAuqjlMpeZPUNT+Cy21KvQbObKIyGx0rryW2peY6VI/vuDPo+3U/YSFkyZXCro2J+PWQTCaK6zU9B4yKIuXy9+DT8eCvZnkYPRYJeJhkRzgjw== 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: Provide a Kconfig option indicating if note_page can be called for intermediate page directories during ptdump. Signed-off-by: Maxwell Bland --- mm/Kconfig.debug | 8 ++++++++ mm/ptdump.c | 26 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index afc72fde0f03..41071539bf9e 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -201,6 +201,14 @@ config PTDUMP_DEBUGFS If in doubt, say N. +config ARCH_SUPPORTS_NON_LEAF_PTDUMP + bool "Include intermediate directory entries in pagetable dumps" + help + Enable the inclusion of intermediate page directory entries in calls + to the ptdump API. Once an architecture defines correct ptdump + behavior for PGD, PUD, P4D, and PMD entries, this config can be + selected. + config HAVE_DEBUG_KMEMLEAK bool diff --git a/mm/ptdump.c b/mm/ptdump.c index 106e1d66e9f9..3c8eea232282 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -26,6 +26,11 @@ static inline int note_kasan_page_table(struct mm_walk *walk, } #endif +static inline bool has_non_leaf_ptdump(void) +{ + return IS_ENABLED(CONFIG_ARCH_SUPPORTS_NON_LEAF_PTDUMP); +} + static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr, unsigned long next, struct mm_walk *walk) { @@ -41,10 +46,11 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr, if (st->effective_prot) st->effective_prot(st, 0, pgd_val(val)); - if (pgd_leaf(val)) { + if (has_non_leaf_ptdump() || pgd_leaf(val)) st->note_page(st, addr, 0, pgd_val(val)); + + if (pgd_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; } @@ -64,10 +70,11 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long addr, if (st->effective_prot) st->effective_prot(st, 1, p4d_val(val)); - if (p4d_leaf(val)) { + if (has_non_leaf_ptdump() || p4d_leaf(val)) st->note_page(st, addr, 1, p4d_val(val)); + + if (p4d_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; } @@ -87,10 +94,11 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long addr, if (st->effective_prot) st->effective_prot(st, 2, pud_val(val)); - if (pud_leaf(val)) { + if (has_non_leaf_ptdump() || pud_leaf(val)) st->note_page(st, addr, 2, pud_val(val)); + + if (pud_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; } @@ -108,10 +116,12 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long addr, if (st->effective_prot) st->effective_prot(st, 3, pmd_val(val)); - if (pmd_leaf(val)) { + + if (has_non_leaf_ptdump() || pmd_leaf(val)) st->note_page(st, addr, 3, pmd_val(val)); + + if (pmd_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; }