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 5F700CD1288 for ; Mon, 1 Apr 2024 19:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD5706B0089; Mon, 1 Apr 2024 15:48:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B85696B008A; Mon, 1 Apr 2024 15:48:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4C846B008C; Mon, 1 Apr 2024 15:48:02 -0400 (EDT) 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 8646A6B0089 for ; Mon, 1 Apr 2024 15:48:02 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 24BB04024B for ; Mon, 1 Apr 2024 19:48:02 +0000 (UTC) X-FDA: 81961998804.05.952FCE5 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf14.hostedemail.com (Postfix) with ESMTP id 3F98310000F for ; Mon, 1 Apr 2024 19:47:59 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OXqAe7li; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712000880; 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=i+aKdwQrYSYkzio8WwLCV972xl0lvZDetZCMBr85V4g=; b=Es/sfs5FjkHhuwP6QXY/YcQdZHTnM/Xv87VxGLba71b6go3uPmpARSuIW60dPh5ktLnCxb xqxh9VuJt3vmckC6PEe5RYOkRnHbt5fL0LAyOyZV2C7V8Tfy7jJF55p2JIMMt7QoZopZLs f1gZCnz0Pf5rAsZUm16+UaxfcsDDvs4= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OXqAe7li; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712000880; a=rsa-sha256; cv=none; b=097ZhHQ0dW5rET86sXdx5l/RDYI0FBS3OdCeocWa3dSjFCngRnJObyWW+DXE4BJJQm7cH3 wCFrG5Gk6gYJn+eL9dhrvwm/GBRhgrxf3uLOYzmRHWQeTnFSC9/L1dpmdGvwL1s14ub1ap EpO1Mqq8OgEjxWgVFSox2oL40BwoESI= Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-415db53d905so363515e9.2 for ; Mon, 01 Apr 2024 12:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712000878; x=1712605678; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=i+aKdwQrYSYkzio8WwLCV972xl0lvZDetZCMBr85V4g=; b=OXqAe7liXsAwTKHE6/+Dcgc0aRtdixAj6qwh9T1V5N2oBQRFE2EKKivimCtsYT55uW +joIuuksEx6rNKheuM1KW7m+fAdE9HkKJP7eIdgN7Y1GmkKlWxEb8ZMSwW8CJhQoOz/V IhkxJLEc0+m2VvXjaFGHsmCGSZYSgmygtSfi7EzAlBJiSiIoF3O2LiNw1cOYdIBqwcu0 GBqGyQPljVUpjU2M89g/uRI7JsEQl3x1s4vkDNxU/u4zfDx4LHLngUBwLfKVRuDOJw0q f6B4P267yUafOd7K2/889zFkyNaF0d0qBZOdHdbKOKfGRvlTb8j9zEKYfi8aDQuMXDfl /WkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712000878; x=1712605678; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=i+aKdwQrYSYkzio8WwLCV972xl0lvZDetZCMBr85V4g=; b=ncpwwFfWoDDHYpRxXYK3tiY37UXVEgp7t7ocQ5AQXLpp5gqt8ucyZ41gc7/bg3KEsR 9X/sHKwibOUaw8QucJS25NHYujcEw8zDSwGF3KZCIAvxJp2hnsJCCDWYrPlOncHw9HgL QfA+euHo1Dtlm3dAqG8/1RyYl30+BaGKy/nGD8mlD/kcJY+WKovTWdkRTucC0jdUnt+t FKW/h36J4giHH7/YDe/b9WMvOZjX9Hm1SQWHP+q2w3fmYLoNImgBS6RJVR2l/3oEq89q E4N6lcd5Zs7+g59ynOq+7ODgYcLCDOpLvjEzMCMM4W9tGpTbK4w1IcEfDGyhxoXHlkDs ZfGQ== X-Gm-Message-State: AOJu0YzPuM3dgoUwDGGwyTHww8VPL8X2vv8BfKrImC9g842+NkhwQkUu xMHldmXsJagWh9kWl1zPBh0sSZTTXsh7f0av9dRk3IKtW7aYNVtb X-Google-Smtp-Source: AGHT+IFMNEfCpuQjJ8WPz+6uM3yEpezsYLuHC2wVq7juE0ooOQEgeuAu2jh/5KYIiQvvkCP2EftuwA== X-Received: by 2002:adf:ea50:0:b0:33e:7fbc:caea with SMTP id j16-20020adfea50000000b0033e7fbccaeamr6898410wrn.34.1712000878354; Mon, 01 Apr 2024 12:47:58 -0700 (PDT) Received: from localhost (host86-170-129-184.range86-170.btcentralplus.com. [86.170.129.184]) by smtp.gmail.com with ESMTPSA id l2-20020a5d4bc2000000b0033e7e9c8657sm12297256wrt.45.2024.04.01.12.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 12:47:57 -0700 (PDT) Date: Mon, 1 Apr 2024 20:45:42 +0100 From: Lorenzo Stoakes To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, stable@vger.kenrel.org, "Liam R . Howlett" Subject: Re: [PATCH] mm, mmap: remove vma_merge() Message-ID: <38b67f6a-6c64-43db-85fb-027efac9d9d6@lucifer.local> References: <20240401192623.18575-2-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240401192623.18575-2-vbabka@suse.cz> X-Rspam-User: X-Stat-Signature: ce3t4a3ftxsttzjf9wugte9wrdr6i8da X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3F98310000F X-HE-Tag: 1712000879-985483 X-HE-Meta: U2FsdGVkX19mkJ3FT7eWYJaB6OMtxQzdDoIlrgD5LpmtHIrdAWC4cppD0RQMVZCwTFOAWWF0bEtXnCT0xVldGjRHllFny/hYyLvTUoL6GlfYc3OH8G2VbYrcYgMGGMx154lGtBsAcAwLHte6ehzFQaH1lSZAj30qEeCQax/4X95Dyxtv4sf/0dQrMpovsMTimAbiUgWfU2TUStzCaVNNVhJtLojJ72cta5B6dSIdSGeUiD6Zemoqo6toA8urlWJ/JxSA8rRR24h6KbNeI3SmNRe3CehVSpuR5TPJ2AwNZNZwEudY49H/HEkzQ5VCo9nhbFUIpLQ6MhT7sZIWcrkWXXYIKU0qf6/pfqQ2vBcp08y0mdqyHN4zCLCLUoL+Lk8Sipdscl00jdR1dlyY0qzZQYFDj8PTXoL2weDax0ufLzny6v08nTWgvcCnQgbmpSUFYf712Lh6uQzFjE8vl5fbhmpVtlLkq8FUw6BtThIt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Q8rw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.015705, 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 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") > Cc: # CVE mandatory > Cc: Lorenzo Stoakes > Cc: Liam R. Howlett > Singed-off-by-one: Vlastimil Babka > --- [snip] This is a beautiful patch and about as perfect a clean up as one could imagine (I mean #thebestcodeisnocode right?), but as we have now eradicated VMA merging, I can't be a hypocrite and advocate for patch merging. As a result, sadly I must: Hope-Liam-Nacks-It-By: Lorenzo Stoakes