From patchwork Tue Jun 18 14:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxwell Bland X-Patchwork-Id: 13702489 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 9621EC27C4F for ; Tue, 18 Jun 2024 15:07:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CA306B00E7; Tue, 18 Jun 2024 11:07:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 178ED6B00E8; Tue, 18 Jun 2024 11:07:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 040BA6B00EB; Tue, 18 Jun 2024 11:07:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D7F1E6B00E7 for ; Tue, 18 Jun 2024 11:07:07 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1E83F4494B for ; Tue, 18 Jun 2024 14:40:35 +0000 (UTC) X-FDA: 82244270472.17.D5736B2 Received: from mx0a-00823401.pphosted.com (mx0a-00823401.pphosted.com [148.163.148.104]) by imf28.hostedemail.com (Postfix) with ESMTP id 58291C0023 for ; Tue, 18 Jun 2024 14:40:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=YzPFJf7R; spf=pass (imf28.hostedemail.com: domain of mbland@motorola.com designates 148.163.148.104 as permitted sender) smtp.mailfrom=mbland@motorola.com; dmarc=pass (policy=none) header.from=motorola.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718721626; 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=bbCv2w4nRPgLR23TBfkseR6W0fRU0+Q29X4EO3LvQgk=; b=S/invT4TbS3Q6lLlqhjBPpYYlSX2exrV64YhY8g+GVr7/2k1EKiOgMdDKY+1IhAjFbtTh7 /EpkxZSxjzugF0GxfHVQeR6JmRQjd7jUNEuALuLt4Fsj3O86op4w/2Ia0AojK+N6YGhot5 Ir4HfQGChbNRvelBNd+FibH39WMsYsE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718721626; a=rsa-sha256; cv=none; b=rToOgqeRUcpDuJ5mj+eB7INrCSbqw3mmICFEDTIKlkPBTUPrLVbAOkD/ovPLuVcszZQMeE d8wHEB5zfcewuwcgc9G7z0KLMtF7Y1s4dm1ffXXNNZ8F5lvejiVC5ZGPhfqhzjvWZBGXMP FBdjFyjEsywlP8NyxjmMhSheE758kKI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=motorola.com header.s=DKIM202306 header.b=YzPFJf7R; spf=pass (imf28.hostedemail.com: domain of mbland@motorola.com designates 148.163.148.104 as permitted sender) smtp.mailfrom=mbland@motorola.com; dmarc=pass (policy=none) header.from=motorola.com Received: from pps.filterd (m0355087.ppops.net [127.0.0.1]) by mx0a-00823401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45IDWdJJ010728; Tue, 18 Jun 2024 14:40:13 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=bbCv2w4nRPgLR23TBfkseR6 W0fRU0+Q29X4EO3LvQgk=; b=YzPFJf7R/tL3nNALkgnits8rxljz2OgU6RY5fzk AeRVWeGyFGWBcLlns6znE2q+PVWu06Wm8Yp4IlO/5BgLoTimcLZ6+97cMttqZUuB vH63gu8rbdihKNQFFbl2+ZgjjvzmUdRK6IUKK4J2pgCeVC7dTdAOqh4FTf36wUI8 Ygvxknxt96dWmJ7QCNbUbMVJEIlucm9XMlYKaFc115kyAR4z+vQYEthfToO4RXx0 T9n0PklJ9pKSa6m7OFVqy61LR6CYg/VFZWNWUnDHWMcFKHAqSjGr13xOWyyPe2hv WfgIYkVZY8hlkoL0IGfQ4URaJqrroF2maumaN8QDrTy0wUA== Received: from ilclpfpp01.lenovo.com ([144.188.128.67]) by mx0a-00823401.pphosted.com (PPS) with ESMTPS id 3ysqth6nbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jun 2024 14:40:13 +0000 (GMT) Received: from va32lmmrp01.lenovo.com (va32lmmrp01.mot.com [10.62.177.113]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ilclpfpp01.lenovo.com (Postfix) with ESMTPS id 4W3Tth1vDHzcxpn; Tue, 18 Jun 2024 14:40:12 +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 va32lmmrp01.lenovo.com (Postfix) with ESMTPSA id 4W3Ttg5fB5z2VZRs; Tue, 18 Jun 2024 14:40:11 +0000 (UTC) Date: Tue, 18 Jun 2024 09:40:10 -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 v4 1/5] mm: add ARCH_SUPPORTS_NON_LEAF_PTDUMP Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Proofpoint-GUID: blkS0LT6wZdY1-TTwIlfF-qhh7xDcsXA X-Proofpoint-ORIG-GUID: blkS0LT6wZdY1-TTwIlfF-qhh7xDcsXA 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-18_02,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxlogscore=618 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406180110 X-Rspamd-Queue-Id: 58291C0023 X-Stat-Signature: yroghzbgjxjn6riisseb7pjc1oh39fbz X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718721630-515567 X-HE-Meta: U2FsdGVkX18L3fe4OxvDoVQI5Li2WxpHFTbjTzUsllPk0hOauwQnLDsJ6KT/SNObLazJsNbUAkRTTzjedKfHNPPBWSwDBZSC0NWSSN4fNw+g0ZKoL34FyTIjRoR2vcGKzltdEXMszojW0or0Cea/USZNOve1QA9ff0PWl5uifNe1cUx7eow2J3eGvCdvGq+RvpK/fb2bHQvrgBbQAYlQHvKaKGTpGcSQulgKu5obyzBtcSSyZjABoF40YT9FzZlJpImsaOZEvomNCOaIP7fK37wbUyZKckS5sMrYXC0YEdl3J1GeGqHqxdCa4a6CaNNBaliL6kgmSEx/s4F6nrlRz9pXZ6SJx7GfzDSrjpNwx4jBwCMIQHwtlVZZ0K41V8wS8W0f1+E5I/2rm5Bj6sk6YU0eXjVMjhrJMEgqk3R7omFDGZDfX7ewayb5XUwhl4PXB4eOWzQ6mdX1ff48nq3gjRYdTKUcgzgCW1ckhMr4CXLAu1aaef6tU0huFqFQqeYP4b7XYEPb+UOfGZ36SkHZolOD5YsXABXOG9BKtfi56QyHZsnonzjqnNSVtjd307AQuiFOycj3sJAGra3o1+Ln+w9/Ly1j6y4PE1lpi4GkeFG7mDZAbi9XEZhbwKHd3Q+BwsfwVTlWXrYH9HynPUKusV0R8hrTBKpQsfpg2woUtsZqu3b3KeGlx/actLIL+SPjbQ7D2yjD+Pv73+yUBbxkP+EvUH1QL2YV0slsqhnu4HBf00nzqcrZG2VWcVc1EGAzIsuWJxqvTxZ5unll6+HHicAO0FbzGTXuQSM/wZ7Pd29LkBPWvIgWNp180J1Px6AYuCqlnRFqlkaOdZwOviNLOhcL/Fez+/NDQY5XC2ylGqAO4jckzfmDxMMd6EvxRp5TtxUb95z5Z2hkjtxkY7DW1Gk7WIJpvblrePFOR8E0Vgc7HOBPRp2A+9aaOr8V422RMDG65bbMO8S3UdxVnfM 8rWHrHUT VNL1rCZVE4vGag9xH/wTXJhm+NP0Mx6Sh3Tu8wTfudZ2yk1HMXs0ne+3ViYeqQuU2wttu9i/b7SBshFwrv1cdCI8ZriXTK5Xh6lN+4wiqr2He3b82szRZR2WaCNEavVOmgY3ivQLsrijl2p8hP+i+G411ojvJx+ycC3DwvVfD1zh65xFbu0PNmWd0d7lQW8DAaRxvX7UMp9CG+/+oAJVTyadHrq3fwee5OfybavslHiNc+DG9ywNiEKyhefvIV1D325fiVRGZG8JM0G518/xO7KaYAPvQZjDGkLUYpR73QOUFWVnLs5A3H1fXEX4aH1Wt/fVxHq/Gw1CcMi8Qe2LDrVjsjG+CTp7rG+7bo5lK4KfI9YB4xPSiAuf+6XIr6jqj5GJf 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 | 9 +++++++++ mm/ptdump.c | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index afc72fde0f03..6af5ecfdef93 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -201,6 +201,15 @@ config PTDUMP_DEBUGFS If in doubt, say N. +config ARCH_SUPPORTS_NON_LEAF_PTDUMP + bool "Include intermediate directory entries in pagetable dumps" + default n + 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..6180708669fe 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -41,10 +41,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 (IS_ENABLED(CONFIG_ARCH_SUPPORTS_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 +65,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 (IS_ENABLED(CONFIG_ARCH_SUPPORTS_NON_LEAF_PTDUMP) || pgd_leaf(val)) st->note_page(st, addr, 1, p4d_val(val)); + + if (p4d_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; } @@ -87,10 +89,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 (IS_ENABLED(CONFIG_ARCH_SUPPORTS_NON_LEAF_PTDUMP) || pgd_leaf(val)) st->note_page(st, addr, 2, pud_val(val)); + + if (pud_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; } @@ -108,10 +111,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 (IS_ENABLED(CONFIG_ARCH_SUPPORTS_NON_LEAF_PTDUMP) || pgd_leaf(val)) st->note_page(st, addr, 3, pmd_val(val)); + + if (pmd_leaf(val)) walk->action = ACTION_CONTINUE; - } return 0; }