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 7C06EC3ABCD for ; Mon, 12 May 2025 13:37:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 387996B0139; Mon, 12 May 2025 09:37:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 334BA6B013A; Mon, 12 May 2025 09:37:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D79C6B013B; Mon, 12 May 2025 09:37:37 -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 EDC626B0139 for ; Mon, 12 May 2025 09:37:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0888516127D for ; Mon, 12 May 2025 13:37:38 +0000 (UTC) X-FDA: 83434358196.29.E733A14 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf20.hostedemail.com (Postfix) with ESMTP id B4BC31C0003 for ; Mon, 12 May 2025 13:37:35 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rqlqwpxY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="TVLRb/iM"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=MeYp35Dy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=6tBEbYPw; dmarc=none; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747057056; 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=JROcxVkua+4AIgLxyA/F6RSaVGE9I8Kot2UvFgn8FMY=; b=XEvQGC3QkWqaCmHqTV8vSgWVA/C9vvUhH5WWfduVpQY1hgS3RrTyCUC0hQnAP/A/MWVeJe BDxkQeZi5wCbYRLZmDCaRipPyomLsvLT1MV7a0nmwOZl8PC5UyPBjFnJ0RPXOPXywdocE8 O/PCSIFcJeiwj+xV2WPOjSSIKCfYRwA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747057056; a=rsa-sha256; cv=none; b=KRjgcHoaW511X3sB2yyZbFoZXlnDsC6KJ5egBc95J9uTuKUf4P+QKm/vAqvB4cmauTMr5c Lka5XPOrPZiHM0C2YjrutMWdB+8yv5X5UKwa1gxgDu1Az0KJhUUhG93VKA+uNUnbOsochm kO9du+FSmnmiVM8UHWCKXWsgXd27fFs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rqlqwpxY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="TVLRb/iM"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=MeYp35Dy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=6tBEbYPw; dmarc=none; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D2DF921180; Mon, 12 May 2025 13:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1747057054; h=from:from:reply-to: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; bh=JROcxVkua+4AIgLxyA/F6RSaVGE9I8Kot2UvFgn8FMY=; b=rqlqwpxY/5Yqv1eWbuwp99XqS+kfuJvDV+GqO21Cy3zjvJJyI3s4mcFqkXjj6aaMNEpR4v dhhGcQ1FlkTtYrG/lrF9ldxB6pki5aMyMzQgR1yLoNyrNf8LAyigAsZ3FNXJ/i7BEszfEd ne/FroC5nlH+paObG/qn3Qpa5aol2Ok= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1747057054; h=from:from:reply-to: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; bh=JROcxVkua+4AIgLxyA/F6RSaVGE9I8Kot2UvFgn8FMY=; b=TVLRb/iM7Z60T426PPm8ySXDc22+ebXwEhmLphOjXy1GZnGZmbLOMPSzbY6u0D31Zdxj7b kxfaMCh0FV4uF4Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1747057053; h=from:from:reply-to: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; bh=JROcxVkua+4AIgLxyA/F6RSaVGE9I8Kot2UvFgn8FMY=; b=MeYp35Dy3PGxhehnvRbdcqcXJMzNk2XpvU6G6F2I6apnekFkBmngzb0yLZh1Xt1A2dGC7A VcgGeyNIDPBm88jAk4OvIeQk3OH56Ot67PenQKPLspKHilNS5Doo1NXJVKpE7oyrOThb6A XlNXS7dZq4uJdRrfbBC3H2Wik97oSww= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1747057053; h=from:from:reply-to: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; bh=JROcxVkua+4AIgLxyA/F6RSaVGE9I8Kot2UvFgn8FMY=; b=6tBEbYPw5EsNjfo81Wq8VZBWh5iOShS5f4xTq4o9tgjz2Q2ikIWwxn6tGZFKAgAfrU4D+O msmgGevynHj7CiCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ACC9A137D2; Mon, 12 May 2025 13:37:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id svnWKZ35IWiqKwAAD6G6ig (envelope-from ); Mon, 12 May 2025 13:37:33 +0000 Message-ID: Date: Mon, 12 May 2025 15:37:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/3] mm: introduce new .mmap_prepare() file callback Content-Language: en-US To: Lorenzo Stoakes , Andrew Morton Cc: David Hildenbrand , "Liam R . Howlett" , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox References: From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: jpbjgukr8bxb6jr3ujn93ko53tgytoqf X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B4BC31C0003 X-HE-Tag: 1747057055-767048 X-HE-Meta: U2FsdGVkX19Wc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oahBQHPZFRmUOe6MKf2F1e34lIk5IcBq5d17JaHUzfPH3LdhumETT52eCSuIdUGc+aUYy11Rru5t3lspKT7+gaerluyLHzueqTVjpP81elPA0jfTIpEekYHPWMoFIyzmhiE888oRPaMb5XVqpBEXFmIsc5vWjts8kOD7OVswvlkweVX3TG8MuWcvfoZbNIvmC1ZS4rJkEV5x/kjDtcQPdsutkAEa8gMx52uGiuCbA9n7vSAQhihpERgUDFdX3dvyuzMmdpP2lIIn2Ks= 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 5/9/25 14:13, 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_prepare() 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. > > The .mmap_prepare() and deprecated .mmap() callbacks are mutually > exclusive, so we permit only one to be invoked at a time. > > Update vma userland test stubs to account for changes. > > Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka