From patchwork Fri Feb 24 10:00:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151076 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 5143AC677F1 for ; Fri, 24 Feb 2023 10:00:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DFEF6B007D; Fri, 24 Feb 2023 05:00:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41A116B0087; Fri, 24 Feb 2023 05:00:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF0B86B0085; Fri, 24 Feb 2023 05:00:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9E1736B007B for ; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 26141A17C0 for ; Fri, 24 Feb 2023 10:00:45 +0000 (UTC) X-FDA: 80501741250.23.CA2CC74 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf16.hostedemail.com (Postfix) with ESMTP id 2CB9018000B for ; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=FkZbX3oM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=D1veafK8; dmarc=none; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 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=1677232843; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=O5q8VKPwKROzkXifx9I8bCKvnOQ0g3mM/tusCr5mero=; b=d6gQb1M19mWPTwd6NrfKcJhQ6z4wNxt2IvvW4CetDpE54TtR0GJW3yp4T2l01tlCcx4Hr9 4tPsdDuS6TqKJy1JX1Gv5Q1MeNaLGELUc2o1EoGzGxq1b4+ro8JUChbpRnM8DJWAwZd4Bu efAqJHOkCYTqWBgfRaDA3IYUCwu6M1w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=FkZbX3oM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=D1veafK8; dmarc=none; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677232843; a=rsa-sha256; cv=none; b=Xjx2M766VaTQjGuwsiY6VR6fpvlUCDxiyqffAU1ktWpldjyOcQ66PZassG+0hyNLebqKiA qeyUKlu31wJcGsIAf23AyulxKLZKy1I3l0A3Oh3Umu2D1qe+44/O8TndPP9q6L1rjZZadN Oa2DHf017rKA0yFHvFowI+QvtV2FSXE= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 00A3A5D557; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677232842; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O5q8VKPwKROzkXifx9I8bCKvnOQ0g3mM/tusCr5mero=; b=FkZbX3oM6Cbh3D9vF4OTlS4FEtmkzdsoP1fdhtB+vIWGIc+CTLYRlTKX8KbFw92wHRGZPk WRX3XrvuWQ3TQDnYUjAqrVH/yf8LuYVwYmGo8G/fpZtwL8+lMKXrD+HOS1lnD/3r9bkWXe hNJNx1Uv/Wl5YHbSfNRCm14Co1q1myQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677232842; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O5q8VKPwKROzkXifx9I8bCKvnOQ0g3mM/tusCr5mero=; b=D1veafK8wyctiXKNfsLpv3h/IxiFkoGpNtuFUV49wvQf76mWBKOGpHONdPSxYiiIA9MSzq 0iLisNPxtDRnFcDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DBAD713246; Fri, 24 Feb 2023 10:00:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iFEFNcmK+GPeTgAAMHmgww (envelope-from ); Fri, 24 Feb 2023 10:00:41 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, "Liam R. Howlett" Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, maple-tree@lists.infradead.org, Vlastimil Babka Subject: [RFC 06/11] mm/mmap/vma_merge: initialize mid and next in natural order Date: Fri, 24 Feb 2023 11:00:17 +0100 Message-Id: <20230224100022.11268-7-vbabka@suse.cz> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224100022.11268-1-vbabka@suse.cz> References: <20230224100022.11268-1-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2CB9018000B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: adzbndcxfioa51pwzjek3m1qzgjqs4wp X-HE-Tag: 1677232842-650981 X-HE-Meta: U2FsdGVkX196JnVcbMCx2WseR4thbu+GCao9BcGfJZiB1VGc0SelbBN3+rk6EyfelmMFDCnc3gvx0K6dm+sNLpIfmw5EoKDmq2Z5jPEuw4w3cH+A23jlULomoU84gmaWPe5p3bjNmCr+yt1cqDfS+YgDENsb0YLqf+CN45Wc012ngZ/FwCKTm3ERkqR5lYB/OWtJDg2tY2ynMHvRxyUixKdsNxOt6B0rvN1M/id+ObT5fTamQM5+GKtUY4zWsoFI4EobCmNg6ChJljZkoxY8XiDh2kbdkLvkn7vPQK75ZIVn4dJNRGSFCRixp1Ib2RdkUI+bdUhGWAkzmESIGA0Wl1RjRV+BSvRV1mrrgNReRHO1U5d2E91j2ZZw6gdWAE7bFP59R318P8ndrfK80dcbAN0yrnaNKrbSL2wnBVWpttX+Y8lKrAczANUTPdHOhqtF+Cc4VcJYuLYXThNB3oL7hr+9E1pWup6viEKcmAfEENGkcJfP0pBjX30pj9k2JUtT4/c/EJ6StT6DfXxcxTXvxg9hxDgbYiOudonjI/DT+FPwG+GH4UkMRSggBLhCY4ji5FFQ9Y/FIh8Xwyp6MuKSdc0Pj0MsaUl+b0zkmqt48sNgxbHJlvOWhtxYC6Vl2U92cfSqKv9xytfz/sHU6S/RrJN8fKA+Yz2ALJkvYcBhFGZopS3y6X0QIYizigsEjE/phaftK31QYatcJXUqvYpQtORX90BaPPcJe2jCS0qXN7e5HrJ3rHeojxzaNXj7oNhdrsX0eSAISJGlyq4JsXacGX71/ezD/LeJi3KAB7vJmD5TBuqC8Zuxir2YxGA3ZomI4HAbLNQEWvdcWFLbfhOBygTKVthB0b5csY2NvuXG/IZWQ9PBhpml1rNMKOCDkr+MkWcjtxRxuaXY7VFmpdvcZO/JD25/PdOiDgKWsj82LAuOLUTebfuSw4JID4Y8RnZkwpnj82XlzFfZuPem6q8 w9WH2Kxv fA8TezVkdv68Ej38x0pSLMysb8co9pZd2HOjmZRlDNj39tFn8adUf0Q2DgYiJhgC8riGMzAAphjm+g04PQX1A+PezP7hGIIhGv0Rmml3NDnyS+dChHKZAveDx2n+ZQFFhHuubM72pbF+4hO2kTBxNHCpOhn3DZW63ACCaEvBh8FohG1psyY/4B2hVIrnbeyxOx+t2GW2hiEeLqloTvvIEO3KZWzVftetw22aW0AEbTGU3Cd9VRWGtWudFeg== 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: It is more intuitive to go from prev to mid and then next. No functional change. Signed-off-by: Vlastimil Babka --- mm/mmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1e4be7174964..e7d497237f44 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -912,10 +912,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, if (vm_flags & VM_SPECIAL) return NULL; - next = find_vma(mm, prev ? prev->vm_end : 0); - mid = next; - if (next && next->vm_end == end) /* cases 6, 7, 8 */ - next = find_vma(mm, next->vm_end); + mid = find_vma(mm, prev ? prev->vm_end : 0); + if (mid && mid->vm_end == end) /* cases 6, 7, 8 */ + next = find_vma(mm, mid->vm_end); + else + next = mid; /* verify some invariant that must be enforced by the caller */ VM_WARN_ON(prev && addr <= prev->vm_start);