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 4D0F4C282D1 for ; Thu, 6 Mar 2025 15:26:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C6E1280002; Thu, 6 Mar 2025 10:26:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94F58280001; Thu, 6 Mar 2025 10:26:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7571F280002; Thu, 6 Mar 2025 10:26:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5045B280001 for ; Thu, 6 Mar 2025 10:26:45 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 901A2C1C09 for ; Thu, 6 Mar 2025 15:26:45 +0000 (UTC) X-FDA: 83191503570.14.888DD80 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf20.hostedemail.com (Postfix) with ESMTP id 28B751C0002 for ; Thu, 6 Mar 2025 15:26:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="dqBp/7Bj"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=jUkQfPAn; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ynNXvnwL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LsmDZdnF; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741274802; 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=lHd/QnzWREQK3Zss6xONiTXxlEVjHm5W37lzvfY3lPA=; b=kluob62kASrHwB2GQYVG6AvzaU3kQF7FlMFEvHk+EjQ7jhumlKFZ2QSpomD58SX7EpjWaf 9qwfqm+tPJZ4Pp2HHk1mm7r53mFFDOyzAC5MenV7aV1iH5RqEINupAv33o8T+1xeUSt4mZ ubNTrdJZQMPe5jTq4dROlDGKlW1pRLo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741274802; a=rsa-sha256; cv=none; b=R4uYxk1CzQ2Tb3NZTyiJHGeBludQaBvzNA7bRD3wDYoDMbiIQtpx6tnvDBNuZefBGm7A5A l8WCuZ7Krl3sABZH9LgaKl1BCY77oDzKxUdxCbNt+gCP1/aGGSNz2wQXIR9kn4ikh3Wm45 jbNJehlw1ZvGead1H5EYvWTkTAWOZPc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="dqBp/7Bj"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=jUkQfPAn; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ynNXvnwL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LsmDZdnF; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none 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-out2.suse.de (Postfix) with ESMTPS id AF2DE1F449; Thu, 6 Mar 2025 15:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741274800; 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=lHd/QnzWREQK3Zss6xONiTXxlEVjHm5W37lzvfY3lPA=; b=dqBp/7BjOAuRnVQmI1pEgYy1/r8afNJZ/82F6j0nIzt8g2bTLy9pBYeVIlmrVAc9P87Lbg zYis9rSh1E0ZNRkwWRWv8OySVYglyWCQAAwi9aPiechXuhAfJHMMVv/eO3YM+Vo5JH071k YnN4cOKYv2+8oaZEgdxKl6RuYhh79Gg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741274800; 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=lHd/QnzWREQK3Zss6xONiTXxlEVjHm5W37lzvfY3lPA=; b=jUkQfPAnJJ19ZdsWyJ7lzUC9AOFOkS8ErIoOUHpewxwvoR4A7o/WSN1B6sXrRHaFxDHCt9 O9RxfbIyaRN4PcDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741274799; 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=lHd/QnzWREQK3Zss6xONiTXxlEVjHm5W37lzvfY3lPA=; b=ynNXvnwLvzEEXs9DOZWyEg8+J798q7l0zalGyrGvhx8Qrj8QK9DY+ekGakKAUZqzRSaY72 khoTbfr9VLiWmByNicWcS6OGj55cPA1hHzjLaAoMmM1kPojY3kRcvqn3Bn5ZsJefSIk5KD KZLdnY+fW3ZUZJ/A+rpR4VRS5pmiha0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741274799; 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=lHd/QnzWREQK3Zss6xONiTXxlEVjHm5W37lzvfY3lPA=; b=LsmDZdnFxE7289PnLJFgyFAhUUREEh89U5ARtGGQrfUCiItiBqHRKARIbFZ6ZpiW/9F1eG qr1O/loCNMLvzoCw== 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 9202813A61; Thu, 6 Mar 2025 15:26:39 +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 1biFIa++yWfDFAAAD6G6ig (envelope-from ); Thu, 06 Mar 2025 15:26:39 +0000 Message-ID: <15c0d1be-4caa-4d72-bad0-b559d9cd8ddc@suse.cz> Date: Thu, 6 Mar 2025 16:26:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/7] mm/mremap: introduce and use vma_remap_struct threaded state Content-Language: en-US To: Lorenzo Stoakes , Andrew Morton Cc: "Liam R . Howlett" , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Harry Yoo , Yosry Ahmed References: <1aeadc40d377fff8796b7c114cb0351c92a68f20.1741256580.git.lorenzo.stoakes@oracle.com> From: Vlastimil Babka In-Reply-To: <1aeadc40d377fff8796b7c114cb0351c92a68f20.1741256580.git.lorenzo.stoakes@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: fmkmxouejh38d98ozc58h3s8wywq179x X-Rspam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812XToDQuFXLywBcZ0rLSRXwTN/781hydD2g8fxI6YKGxXw8E4SNQS1lKU2kbhqc+3RxxJr65K50ZypwGxcMa5cCCB6zgZx0ufe+KvOirnmBwZKSKNL2y8/sFPVmcT1g8FVRaKpjXoFgwJcr5w55ltyaZtUN1mwV3Qxs6XVUlsnDi9P2nYJm6eKYS4o8gP7+7HFqv46uWinj5ZVQ+xWB066fSD+fiLrYS6pWSGRDsZANM2yso00FonX+0h6McbfILyrbmdVrj1vkULNUK9FcwWAPXUS7emdOkWC6wInptDaCjDDAUQpxBIR9uw+kA5W/fDzSZfF X-Bogosity: Ham, tests=bogofilter, spamicity=0.296105, 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 3/6/25 11:33, Lorenzo Stoakes wrote: > A number of mremap() calls both pass around and modify a large number of > parameters, making the code less readable and often repeatedly having to > determine things such as VMA, size delta, and more. > > Avoid this by using the common pattern of passing a state object through > the operation, updating it as we go. We introduce the vma_remap_struct or > 'VRM' for this purpose. Small children here make such a 'VRM' sound when imitating a car. > This also gives us the ability to accumulate further state through the > operation that would otherwise require awkward and error-prone pointer > passing. > > We can also now trivially define helper functions that operate on a VRM > object. > > This pattern has proven itself to be very powerful when implemented for > VMA merge, VMA unmapping and memory mapping operations, so it is > battle-tested and functional. > > We both introduce the data structure and use it, introducing helper > functions as needed to make things readable, we move some state such as > mmap lock and mlock() status to the VRM, we introduce a means of > classifying the type of mremap() operation and de-duplicate the > get_unmapped_area() lookup. > > We also neatly thread userfaultfd state throughout the operation. > > Note that there is further refactoring to be done, chiefly adjust > move_vma() to accept a VRM parameter. We defer this as there is > pre-requisite work required to be able to do so which we will do in a > subsequent patch. > > Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka