Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1899085lqz; Tue, 2 Apr 2024 00:29:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXiRzQUiQircs7n3XsrfmeWe0qxsBukkWQ6i5aLsjp1t0+OmhS6NFyxKorb0idOMqiRY5qCRdGalXMVAywOGbnjW/rOWox/6piSd8G+Vg== X-Google-Smtp-Source: AGHT+IEcliih83zEBjEYbgjfO3eyc42X6zKEQ1yF0r26AemRquhNV0y9xY9stKj4+TSSL5A6ceOZ X-Received: by 2002:a17:90a:ca03:b0:29b:10bc:acaf with SMTP id x3-20020a17090aca0300b0029b10bcacafmr9116132pjt.30.1712042990345; Tue, 02 Apr 2024 00:29:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712042990; cv=pass; d=google.com; s=arc-20160816; b=efye5zXF37wFFOk3/6f98JT8I6FtCQ1oDYTjwW3H0A42/9GCadIwAqLEybIj1EEYZr 1LvkQIYcdMyseGp616KWlmSUFnp97cg2a4BOYZPx3VawvF3EaNFgJicXTD8+izt/wSDf cT1kbNvWzlcjj6v5hvVMPBpwFO/QiGeZU7OF5YfrdDj8fC0m4wQGwTXyOJjEQLNIyFMI FA+aV6oFHlZdQyTiWQLNDQpEeMYRbGpJDaZI0rwkwsAvm3p3dS6zWCMQd0Y5e+xwuLHU VyYbSiVDlLdw/5e2T6CSfb0CZPzDei83GYcFqVyV7MkvXuF4owzUtn96a9N674Qg7TfJ PIlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kmXagDsf1ccCwe3Y7JKUKeOyOMpGB+APUPzMlq2XWyc=; fh=N46TfsefN+QLS07oNikCWIosHl8MO+J5mUIhBtMg4kM=; b=oYrgvgM15mjhh53SvUwwxVob980aZF95NJWnpd6cv9tFNFKSNpQct308nmHZbSij/I W2Ih/6AjioSpoitHRQ5yRJzXaTPPuyRxcy81u0xkQXw7mO2bbUF2+W67QFnJHcX06ArX rBovxHlnjjdtZu8rK4C0QZRWxrUs3G6AuK3KtQz1SqKm4ExeeswQdeG9Os83w0sl9bqO mkzcsTv40UoZAb/1HnL52tzGBtcfki5D4b/GxvUSCfeZCoLpouh2juys4Uxwt7x1YdK3 O3NjiY+oB95eRkRokBPfdeGW0MHzikZy78NYZUDdPyXBb9ELtcZwSTx9EBBvwCtn6VGl frug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GjDkGXRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m22-20020a17090a159600b0029df6f09f11si10682741pja.73.2024.04.02.00.29.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 00:29:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GjDkGXRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4B509B22576 for ; Tue, 2 Apr 2024 07:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEEB83D0C4; Tue, 2 Apr 2024 07:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GjDkGXRL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02B993CF65; Tue, 2 Apr 2024 07:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712042967; cv=none; b=jtnoRBv4Ig1mi59DFStvgfv29JSUVV6m16m0WEnOnyq/+fyOPvtdFUkYmEwgf7iZmF2BPfRuh6htzq+ezj8bI9g5V662sPtPe333wYIuYKAgADyMZ0DkCTEiL7/+1BU2km0UP/4R6N5M/31j1Z2OW4pSZlmCIUTybxtxC7eWINE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712042967; c=relaxed/simple; bh=qOicry9z85KjMA4krUEtV2LPv7uV/eb02RvZJJGSRL8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MRke16A8MnAPSrb/4wuIEEWE5XohDSuKcMSY0lpcS/cLMSzw6YhoP9F9kX4j5b+en7L90zpMkOzfJv2RvkwMtZ+SA0xprF1dJZjcqvs3n8+RhtK1WZyYZggi/cuQD88wH2n6LDgv4KSoTj27sMoZAjyOt7yrkhqBro7wxBbkMHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GjDkGXRL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01353C433C7; Tue, 2 Apr 2024 07:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712042966; bh=qOicry9z85KjMA4krUEtV2LPv7uV/eb02RvZJJGSRL8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GjDkGXRLeXSxlcRYovEB1Pee7Y+iEj/+JSbkC/aQYrhaT6zD57IZwO5zf3+ec70PZ CT86MYuJ4MXeuGNT90V5/Fyj5XSGha15SZz0Pz+Jr0D+z4UfBnaldBxegqdhes8P6V PAcwNb+Gqm9cCWq+JYNld2RGNAVRz0lT6gMSBCARt43nfawALplsMH2OEpJjep/f0g TUr8SZjyPcNUZCDpAvnxMURbmEpRcmbLkA4kMm5swqlejelwTqiHT1Nw2BO54a43Wg +pUmtQZSjkg4H2HuAVHYaE35aaZ764YiKT7/KFDmQ8HX5D3KLlaudHVmwgfK/VKqWH JQrCC45iSNBmQ== Date: Tue, 2 Apr 2024 10:28:42 +0300 From: Mike Rapoport To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, stable@vger.kenrel.org, Lorenzo Stoakes , "Liam R . Howlett" Subject: Re: [PATCH] mm, mmap: remove vma_merge() Message-ID: References: <20240401192623.18575-2-vbabka@suse.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240401192623.18575-2-vbabka@suse.cz> On Mon, Apr 01, 2024 at 09:26:24PM +0200, Vlastimil Babka wrote: > With SLAB gone I was looking for what I could delete next, and then it > dawned on me - it should be vma_merge(). It's simply an unmaintainable > mess. > > The code is extremely hard to follow. There has been a number of recent > attempts to made it more readable, by Liam, Lorenzo and myself. Almost > every time this only resulted in subtle embarassing bugs [1] [2] [3] [4] > [5]. For many of the bugs the only reliable testcase we have is the rpm > process running in the Open Build Service. Which is worrying, as that > clearly makes vma_merge() a potential supply chain attack vector for > planting backdoors. > > Thus simply remove vma_merge() and all the related code, and adjust all > callers to take the path as if merging was attempted and failed. > The only downside is that there might now be more vmas and maple tree > nodes due to no merging. To extensively validate that, I've booted the > kernel with virtme-ng before and after the change and checked slabinfo > for the number of active objects: > > before: > maple_node 1159 > vm_area_struct 1538 > > after: > maple_node 1113 > vm_area_struct 1861 > > Yeah there's more vma's but interestingly, less maple tree nodes. I > believe it's worth it. The larger number of smaller vmas could even help > with better parallelism thanks to per-vma locking. So the conclusion is > obvious - we should have never tried merging vmas in the first place, > hence the tags on this patch. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d014cd7c1c35 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4c6759967826 > [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7e7757876f25 > [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1419430c8abb > [5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc0c8f9089c2 > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") This is hilarious, stable folks will be excited :) > Cc: # CVE mandatory > Cc: Lorenzo Stoakes > Cc: Liam R. Howlett > Singed-off-by-one: Vlastimil Babka > > --- > mm/internal.h | 7 - > mm/mmap.c | 368 +++----------------------------------------------- > mm/mremap.c | 60 -------- > 3 files changed, 17 insertions(+), 418 deletions(-) -- Sincerely yours, Mike.