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 38F3FC369DC for ; Thu, 1 May 2025 12:17:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7FC06B0088; Thu, 1 May 2025 08:17:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2F0B6B0089; Thu, 1 May 2025 08:17:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F8056B008A; Thu, 1 May 2025 08:17:18 -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 818DC6B0088 for ; Thu, 1 May 2025 08:17:18 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EE18E1207CE for ; Thu, 1 May 2025 12:17:18 +0000 (UTC) X-FDA: 83394238956.08.55D588F Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf29.hostedemail.com (Postfix) with ESMTP id 552F5120011 for ; Thu, 1 May 2025 12:17:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CM259zVu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746101837; a=rsa-sha256; cv=none; b=RN2xLqITN25U+k3MI0/sbnKyIHsYEjo4MiArafrkJvWLyn9ChWDu8aRxNrqOw+S/OAXopF dXfrHPvrBpGhnk6A9rsQL1efgaT2uE4xDSCzJpS7DFfcsiL5IyY/KUoua2C6YLz9dOeWuq 81d5gYj+dycvUr+M7V0Y7ufU7tiF5F4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CM259zVu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746101837; 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=WooIIopbLCp/nKJyvn/e9SXK4anXR2j245UOFS0nmjA=; b=PSgYtNGXaMG0Qzd8+GoMGDFLMTaVmG+TNO/TlcVfEKsVV+64HIBYqp5EQokVYaEVUzUhCb XXHC6BY96/wpDgRGEo1hLYRIRoOBdDX05p/0iTgV6I9SVCehrTAyCUNC/+t3lGup/bS0tD uc9M8RIgoEzKNyyaBf1ZneZvu36/8QQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id A267A68468; Thu, 1 May 2025 12:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05545C4CEE3; Thu, 1 May 2025 12:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746101836; bh=a7VyWzbLsXgj9plmo5+OkoEU6S32yqKBmnsZ5ada3EQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CM259zVuI12c6B8yJGt4xuuGFcwl7G3oFP2FnevTmzXZE1hgPB3RimiTtjCaRNvgV WMSBQuB365NPgNaQE9ZjZs97E0QlPE96jb486tK2LX3jixJvNPkI4KauF6YytT/BNy hVFbfifO1VKeCrKzJp7R1fx3BvwtAzRKMHtG5s0SuIa87xufoQgXErQdzmDtjDM/We NXWlWzCP6VO83HZbjWjwvtmWtiM1QHaFeqEMLY4U6uKvn+Kl+nnEmaVeRgxtSQ/S2Q zaqF4RRkeyOaysQDk4KNdDogoQmTAEtihGYHmGjedJ8GORArrbBfGTl6HDJbO/IR+F jmL32GVyCxwUA== Date: Thu, 1 May 2025 15:17:07 +0300 From: Mike Rapoport To: Lorenzo Stoakes Cc: David Hildenbrand , Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , Pedro Falcato , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , Christian Brauner , Jan Kara , Suren Baghdasaryan , Michal Hocko Subject: Re: [RFC PATCH 1/3] mm: introduce new .mmap_proto() f_op callback Message-ID: References: <7ab1743b-8826-44e8-ac11-283731ef51e1@redhat.com> <982acf21-6551-472d-8f4d-4b273b4c2485@lucifer.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <982acf21-6551-472d-8f4d-4b273b4c2485@lucifer.local> X-Rspam-User: X-Rspamd-Queue-Id: 552F5120011 X-Rspamd-Server: rspam04 X-Stat-Signature: d64zrtrreme1rdr6jmghw6wzpj55d7iu X-HE-Tag: 1746101837-362403 X-HE-Meta: U2FsdGVkX1+UPTY7yn+Lax95Bbg4RG5+LJzOmQFEj5l+W5fCMUwchg/l97VtCJ5eEW1RRsMp7hxkfnw8a8max2TZT4ENZ78Z5YuIQmWuafv2A+5jMpw1+T1DFsqAxdm2uX4RMNUSHBYP4uww+p+hscWPRMEYq/eXEDMOcdODj6ARGyLyNNxE1ztad98YM9t5hYOBnQV0gkQSLCyr+pd9nkrjtSzpwW2xWV8x751iS2EylBn2Bi6T50AhsO2F7zow4Mr8q9GvWVfi/LIxQ63Yd0EXSlCp3mV68XIIyzALBv94JiFdRANcDXrZzRXFzquW9NTQcscvyWcrBZuPzGeb7BizvPYg8C7cSq7Uyk45blLCOp5TcaP/eZQT8/CuHnjx9gvADAVByAN+kiGmCEZQdMYV94X66BAVrvU915sbEsl6rQ3q2OWZZEK2hgxkzz6XmWZsNdun+o6kUu/MwhZHf5vP7+uzlxXNEMAHkf2r7ooKo/CR413g0WKpKVlMXRoeRmio3zSyifyoFKIxWeP9L841TNpEbf3lA2v7wYaNrMtTJN9ThUs+5khxMcZGSQjlkKgr/C83P5WFZbugpnbGrZD55vMZL5tT/A2ANezV3z0PLoawL1Oj6476faGIhizM7wotGbrOgA9hi9ZLEjDN4YMFcV3+zIZ0j/A6a+bTwRbJ4mX7yISQydz0xTN+Vwgx6+FrrUtIQDvkKW8Pj6T8g3gCkMVCK1j9myOgnBhkbSR/c7fVEyMAYTDh04Jb5nA4Wnx3pYwyW5P3pUwnbSA0cNO680cN2HS8t11C9jujx+JZSnmKYbeGy9sp63ujhbZdj+MZzpiubomuyhoG3hPdWyscPofGDWcf+K7ugOi65sdU2YVJP1EIuVo2wZp200JO2mlJgq8RzOxCEsqP2eHlleI4qMO1NrGHp5KfUZtSZrC9yhabOdDfrkOIY7Ho4IPF5QvtyGnOCWhPdq60VXN Rcgw+CRQ qud3Yyrb/PGdYYpsdzNBIiwrchdJ7D/utrYpoUj2awQo1wlu0BG3tbzJyfL82brC12Mh6A0bhjf90+rp6Hpn/g5APPUE7ONyEmDjS4Qk2dO9EnKPVnsd6cN1Kf7LEkIdtEiZiVciXRCEVMJod/3qZTEWtNBb4RzelzwlGmyHkSjcmIisKvcWhI9EsomHKcJMXTh2xdI6tDFSW8RrFaPNfWNjwjsD30l3TRBerbtuMktZa8Emh2Zx2wiwY5fcprPPGggSpVJpoS6HArc7uaMtOLwQRKZ8idknQTiUdZ3rXs9rF0hvpPVxdG6q4XtLzIwKAH8N+ 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 Thu, May 01, 2025 at 11:23:32AM +0100, Lorenzo Stoakes wrote: > On Wed, Apr 30, 2025 at 11:58:14PM +0200, David Hildenbrand wrote: > > On 30.04.25 21:54, Lorenzo Stoakes wrote: > > > Provide a means by which drivers can specify which fields of those > > > permitted to be changed should be altered to prior to mmap()'ing a > > > range (which may either result from a merge or from mapping an entirely new > > > VMA). > > > > > > Doing so is substantially safer than the existing .mmap() calback which > > > provides unrestricted access to the part-constructed VMA and permits > > > drivers and file systems to do 'creative' things which makes it hard to > > > reason about the state of the VMA after the function returns. > > > > > > The existing .mmap() callback's freedom has caused a great deal of issues, > > > especially in error handling, as unwinding the mmap() state has proven to > > > be non-trivial and caused significant issues in the past, for instance > > > those addressed in commit 5de195060b2e ("mm: resolve faulty mmap_region() > > > error path behaviour"). > > > > > > It also necessitates a second attempt at merge once the .mmap() callback > > > has completed, which has caused issues in the past, is awkward, adds > > > overhead and is difficult to reason about. > > > > > > The .mmap_proto() callback eliminates this requirement, as we can update > > > fields prior to even attempting the first merge. It is safer, as we heavily > > > restrict what can actually be modified, and being invoked very early in the > > > mmap() process, error handling can be performed safely with very little > > > unwinding of state required. > > > > > > Update vma userland test stubs to account for changes. > > > > > > Signed-off-by: Lorenzo Stoakes > > > > > > I really don't like the "proto" terminology. :) > > > > [yes, David and his naming :P ] > > > > No, the problem is that it is fairly unintuitive what is happening here. > > > > Coming from a different direction, the callback is trigger after > > __mmap_prepare() ... could we call it "->mmap_prepare" or something like > > that? (mmap_setup, whatever) > > > > Maybe mmap_setup and vma_setup_param? Just a thought ... > > Haha that's fine, I'm not sure I love 'proto' either to be honest, naming is > hard... > > I would rather not refer to VMA's at all to be honest, if I had my way, no > driver would ever have access to a VMA at all... > > But mmap_setup() or mmap_prepare() sound good! +1 and struct vm_area_desc maybe? > > > > > > In general (although it's late in Germany), it does sound like an > > interesting approach. > > Thanks! Appreciate it :) I really want to attack this, as I _hate_ how we > effectively allow drivers to do _anything_ with VMAs like this. > > Yes, hate-driven development... Just move vm_area_struct to mm/internal.h and let them cope :-D -- Sincerely yours, Mike.