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 BA169C49EA1 for ; Tue, 6 Aug 2024 14:13:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CD5C6B0083; Tue, 6 Aug 2024 10:13:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47D536B0085; Tue, 6 Aug 2024 10:13:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 345516B0089; Tue, 6 Aug 2024 10:13:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 148506B0083 for ; Tue, 6 Aug 2024 10:13:31 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7AE7D140236 for ; Tue, 6 Aug 2024 14:13:30 +0000 (UTC) X-FDA: 82422013380.30.F73E9A1 Received: from bee.tesarici.cz (bee.tesarici.cz [37.205.15.56]) by imf27.hostedemail.com (Postfix) with ESMTP id ACD9F40016 for ; Tue, 6 Aug 2024 14:13:28 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=tesarici.cz header.s=mail header.b=F84+kY2o; spf=pass (imf27.hostedemail.com: domain of petr@tesarici.cz designates 37.205.15.56 as permitted sender) smtp.mailfrom=petr@tesarici.cz; dmarc=pass (policy=quarantine) header.from=tesarici.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722953577; a=rsa-sha256; cv=none; b=nl5XEEwbdKZ700XJt90VHPdPQKCeu0yrbqzQ3aBbGhbBrzn6fToXwiJlY/GxHamVyw9Kl3 R3KnX+fwAJVZn+vH5i9s6YDZiGE0SmDkYn2pCnIW7h5bNtLZYQ1mjvtJrvjuWePpDLRJg/ 0ICGEU1TazCPkUbkjJRrK3N0i9H/g/8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=tesarici.cz header.s=mail header.b=F84+kY2o; spf=pass (imf27.hostedemail.com: domain of petr@tesarici.cz designates 37.205.15.56 as permitted sender) smtp.mailfrom=petr@tesarici.cz; dmarc=pass (policy=quarantine) header.from=tesarici.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722953577; 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=cJb2Uk7f82JabnNdlQgrJWXTdXU9z5U0J91nQ9WPQIk=; b=27l+uCvkP0TKmbXzgoP9I58x8+guX4b9zQg12lwaPm7uGQox0FarF1vqzgnuaHEEKtE8X5 vranjiBi9VOqfB8f9vSYl9U0sFWm7YM+ovoKbqVniZg1ZW5/uVQT2yfJ0FNoA+mZZLMUwf wnt79SkfwIB+EG2CBTNsLfw3In20aQg= Received: from mordecai.tesarici.cz (unknown [193.86.92.181]) (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) by bee.tesarici.cz (Postfix) with ESMTPSA id 4C5471D3CA6; Tue, 6 Aug 2024 16:13:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesarici.cz; s=mail; t=1722953606; bh=cJb2Uk7f82JabnNdlQgrJWXTdXU9z5U0J91nQ9WPQIk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F84+kY2oVmz2zvaw19agogDetBSi1mVwVLvFriSpJlz9se2y7wgYsDMj7uWKW9IYn UAZ456F6HGgzpHJ4NDx+JOHl65iAK0zNQzGNpOE+F/SVk9ro3qt8jC2F54nXxlHjou vBl89hp1QpLi2eyuGK3fMLIsqEtUrbBY39YrHOKROqvFp4byh8BBkWBKvKvRA3cWHM iwUP3tWBe5OVWtY++joboNGXikAgvcXI/NO51mNrYTT+YNFLpfpydMjqwmBYJoMQjA 6P0SOWW9g2kq8aKunmv5ZYoEDoGO0wBlvCFJYko/NKGbgrMBBVvzU9sOFb5uDbydw2 DsdqoyC39CMcA== Date: Tue, 6 Aug 2024 16:13:21 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , "Liam R . Howlett" , Vlastimil Babka Subject: Re: [PATCH 08/10] mm: introduce commit_merge(), abstracting merge operation Message-ID: <20240806161321.376f0a55@mordecai.tesarici.cz> In-Reply-To: <415d9d9c-7b63-47f0-9091-678f0d8d1268@lucifer.local> References: <3b04eb13b499df3ebf50ae3cde9a7ed5e76237fd.1722849860.git.lorenzo.stoakes@oracle.com> <20240806154116.015e329a@mordecai.tesarici.cz> <415d9d9c-7b63-47f0-9091-678f0d8d1268@lucifer.local> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: hir9hptcifxgat59u8xrrypbngrpffby X-Rspamd-Queue-Id: ACD9F40016 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722953608-179844 X-HE-Meta: U2FsdGVkX1/1w/ZRxphx1AGVFlp4zvd9iV9SW5f0UNxAbGwU/WI0urpMJNklH2hN1kbE+f1a+oZJDS+4E95vRaEkO3PIspS3a3y1Qm5qJ2BYB3iQR/2NM51exKo5O0cxUkBIZujpiQ1KoBMEvioGtTvd6gCMppC9AzdHruCM1MwhNnm2wm2JEeXzqbdvayqgI0q8eVro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9DWwl8SVCi0EBKrE/kZEw8DJRoCZEq7cBrS7ADe9Kz3mviYDrMO22HwTjcGHhdVHuiC/nQCNw1U7MOtYh2Y8FmqyXlW2cWfOrN4LdFOXN1LW4EcQekJcbuZ84 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 Tue, 6 Aug 2024 14:48:33 +0100 Lorenzo Stoakes wrote: > On Tue, Aug 06, 2024 at 03:41:16PM GMT, Petr Tesa=C5=99=C3=ADk wrote: > > On Mon, 5 Aug 2024 13:13:55 +0100 > > Lorenzo Stoakes wrote: > > =20 > > > Pull this operation into its own function and have vma_expand() call > > > commit_merge() instead. > > > > > > This lays the groundwork for a subsequent patch which replaces vma_me= rge() > > > with a simpler function which can share the same code. > > > > > > Signed-off-by: Lorenzo Stoakes > > > --- > > > mm/vma.c | 57 ++++++++++++++++++++++++++++++++++++++++++++----------= -- > > > 1 file changed, 45 insertions(+), 12 deletions(-) > > > > > > diff --git a/mm/vma.c b/mm/vma.c > > > index a404cf718f9e..b7e3c64d5d68 100644 > > > --- a/mm/vma.c > > > +++ b/mm/vma.c > > > @@ -564,6 +564,49 @@ void validate_mm(struct mm_struct *mm) > > > } > > > #endif /* CONFIG_DEBUG_VM_MAPLE_TREE */ > > > > > > +/* Actually perform the VMA merge operation. */ > > > +static int commit_merge(struct vma_merge_struct *vmg, > > > + struct vm_area_struct *adjust, > > > + struct vm_area_struct *remove, > > > + struct vm_area_struct *remove2, > > > + long adj_start, > > > + bool expanded) > > > +{ > > > + struct vma_prepare vp; > > > + > > > + init_multi_vma_prep(&vp, vmg->vma, adjust, remove, remove2); > > > + > > > + if (expanded) { > > > + vma_iter_config(vmg->vmi, vmg->start, vmg->end); > > > + } else { > > > + vma_iter_config(vmg->vmi, adjust->vm_start + adj_start, > > > + adjust->vm_end); > > > + } =20 > > > > It's hard to follow the logic if you the "expanded" parameter is always > > true. I have to look at PATCH 09/10 first to see how it is expected to > > be used. Is there no other way? > > > > Note that this is not needed for adjust and adj_start, because they are > > merely moved here from vma_expand() and passed down as parameters to > > other functions. =20 >=20 > See the next patch to understand how these are used, as the commit message > says, this lays the groundwork for the next patch which actually uses both > of these. >=20 > I have tried hard to clarify how these are used, however there is some > unavoidable and inherent complexity in this logic. If you don't believe m= e, > I suggest trying to follow the logic of the existing code :) >=20 > And if you want to _really_ have fun, I suggest you try to understand the > logic around v6.0 prior to Liam's interventions. >=20 > We might be able to try to improve the logic flow further, but it's one > step at a time with this. What I mean is: Is there no way to arrange the patch series so that I don't have to look at PATH 09/10 before I can understand code in patch 08/10? This PATCH 08/10 adds only one call to commit_merge() and that one always sets expanded to true. Maybe you could introduce commit_merge() here without the parameter and add it in PATCH 09/10? Petr T