From mboxrd@z Thu Jan 1 00:00:00 1970 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 0095DC5B552 for ; Wed, 4 Jun 2025 08:07:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81DC06B05A7; Wed, 4 Jun 2025 04:07:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CE9B6B05A8; Wed, 4 Jun 2025 04:07:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BD1C6B05A9; Wed, 4 Jun 2025 04:07:20 -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 4D5B06B05A7 for ; Wed, 4 Jun 2025 04:07:20 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A00ED1A0AB2 for ; Wed, 4 Jun 2025 08:07:19 +0000 (UTC) X-FDA: 83516988198.04.BF5653E Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf04.hostedemail.com (Postfix) with ESMTP id EE7DA4000A for ; Wed, 4 Jun 2025 08:07:17 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UkoN+a3z; spf=pass (imf04.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749024438; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+60S90aj+2ssI+GeKIuBz7T0qrEYMfCPtXMhekAbcpg=; b=Nx6EsWW/vvR0IbPRieqVGOJx/mslillMKJ/6405e1GJfUOZ3QysISg6Mv9acmkD8UmwWYO PGDvPxZj1eGnAlfm8GpJzFEIH21JioJDqpb787YZYjezLiWd2GdCTMh54aAMTa4ABcralr BvlDJIPQ4t7Y9b1cgM65G3KPslKKZDo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UkoN+a3z; spf=pass (imf04.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749024438; a=rsa-sha256; cv=none; b=EZLi0cALUurqrGwhrt46/8+t6y6yImbFV765nlIIxCQqUHDKaAtiqKahKuzNqqo6Eylryv siE+Jk1I/N7QwSTXgg+GtQcfxsF3lkW0KmCfYi0EiJyccIfJJgeTSRRVHBXXnXQuxL0Xde bbUQYtcW8jcxTzgGoDPZvRnoc1M35AE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 589AFA50155; Wed, 4 Jun 2025 08:07:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90A0AC4CEE7; Wed, 4 Jun 2025 08:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749024437; bh=yhf7uIemDFvOFZs2ab9B2tbrEfAJeioCFyGpvougiYw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UkoN+a3zAHKzxBIHiRC/IlPuT0QSuatYT+VGDnR+NiAJTDjSYu7ZxSKc6OtO3Sjnm p9OKsigQudSpIeAXqCHw/58NONlyuoRuEXMP3isFFcNjqKiLC1mfn0HvwTt6lVdy2J W5V6zRyyi7KgHPk9CsPgnCjTZSvT9Y6yl9RO+baEI1r3bqZC8IO3brMlu8pGr5dQlB JJuNJ+yyDgAz/Ro7+eGjf3MrBrzlv9RVLswj2/I0pUN8Ae1nA0CzPMWIV49FLAj2dX ovNfHEuBbIS2qc7uGqlkuB7GuYGHvg9vuitN6/j5zZhFB8kPoIC4zmvLHgUU15nvUt qEKucBZNRJ20g== Date: Wed, 4 Jun 2025 11:07:05 +0300 From: Mike Rapoport To: David Hildenbrand Cc: Lorenzo Stoakes , Andrew Morton , Barry Song , "Liam R . Howlett" , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Muchun Song , Oscar Salvador , Huacai Chen , WANG Xuerui , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Jann Horn , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH RESEND] mm/pagewalk: split walk_page_range_novma() into kernel/user parts Message-ID: References: <20250603192213.182931-1-lorenzo.stoakes@oracle.com> <51ec4269-b132-4163-9cb5-766042a3769d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <51ec4269-b132-4163-9cb5-766042a3769d@redhat.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EE7DA4000A X-Stat-Signature: xypii8mwa887noomuumr9mubr96hzjdo X-Rspam-User: X-HE-Tag: 1749024437-267740 X-HE-Meta: U2FsdGVkX1/KjH0PibPojxDs3T26ubt7pCK3mKcAlzAFxY1/wY3mZed6AuwZ4uOfzF/6FTxs6dPag9c0zYOeYfuliA7+SB2ApCeC68NsnEjRt7vC+l9o82pqJDaiEsBEGWvnGcELY+sQL8dVbJfq9cSJCXL5SsWTLx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zYeZ0ZBGQ680g2OKQ2/V+Wiez/QAqnZpIQlMewpVJofJTIqPUdfvJFGBbkPFGQ= 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: On Wed, Jun 04, 2025 at 09:39:30AM +0200, David Hildenbrand wrote: > On 03.06.25 21:22, Lorenzo Stoakes wrote: > > The walk_page_range_novma() function is rather confusing - it supports two > > modes, one used often, the other used only for debugging. > > > > The first mode is the common case of traversal of kernel page tables, which > > is what nearly all callers use this for. > > ... and what people should be using it for 🙂 > > > > > Secondly it provides an unusual debugging interface that allows for the > > traversal of page tables in a userland range of memory even for that memory > > which is not described by a VMA. > > > > This is highly unusual and it is far from certain that such page tables > > should even exist, but perhaps this is precisely why it is useful as a > > debugging mechanism. > > > > As a result, this is utilised by ptdump only. Historically, things were > > reversed - ptdump was the only user, and other parts of the kernel evolved > > to use the kernel page table walking here. > > > > Since we have some complicated and confusing locking rules for the novma > > case, it makes sense to separate the two usages into their own functions. > > > > Doing this also provide self-documentation as to the intent of the caller - > > are they doing something rather unusual or are they simply doing a standard > > kernel page table walk? > > > > We therefore maintain walk_page_range_novma() for this single usage, and > > document the function as such. > > If we have to keep this dangerous interface, it should probably be > > walk_page_range_debug() or walk_page_range_dump() We can also move it from include/linux/pagewalk.h to mm/internal.h > > > > Note that ptdump uses the precise same function for kernel walking as a > > convenience, so we permit this but make it very explicit by having > > walk_page_range_novma() invoke walk_page_range_kernel() in this case. > > > > We introduce walk_page_range_kernel() for the far more common case of > > kernel page table traversal. > > I wonder if we should give it a completely different name scheme to > highlight that this is something completely different. > > walk_kernel_page_table_range() > > etc. > > > -- > Cheers, > > David / dhildenb > -- Sincerely yours, Mike.