From patchwork Thu Mar 9 11:12:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13167257 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 CBC85C742A7 for ; Thu, 9 Mar 2023 11:13:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 486B96B0072; Thu, 9 Mar 2023 06:13:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37AF66B0075; Thu, 9 Mar 2023 06:13:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1601D280001; Thu, 9 Mar 2023 06:13:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DA1DE6B0072 for ; Thu, 9 Mar 2023 06:13:14 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A19841410C7 for ; Thu, 9 Mar 2023 11:13:14 +0000 (UTC) X-FDA: 80549098308.21.F76682C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf26.hostedemail.com (Postfix) with ESMTP id C733E14001E for ; Thu, 9 Mar 2023 11:13:12 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lF0QP81+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=yKYa9OI8; dmarc=none; spf=pass (imf26.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=1678360393; 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=MSk6Q5fXV5lgNPoon595PuYz0dxCHrt88iESPc6EpdI=; b=bMHe6zHVMe2HDrpkF8quSO5xvjs9EgOpTA7kJ/Lxtinvv6sCk3D8l0Gk+QpHkkX5qykSPK 8iz3aBicvWLjxwEGbGekbC55TKG7rZvMrpFPTrnit/6t7dsKAOm38fZbfoR3UbyjjwVKbk vVUz1KWeckMDTPDhpZ9KlzFJKTB3tO4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=lF0QP81+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=yKYa9OI8; dmarc=none; spf=pass (imf26.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=1678360393; a=rsa-sha256; cv=none; b=3t6xSvDlaZadDJzUin7whSJpFASKUpDvfcb26+lExOyVyktPiAbpCmDuKDLTfDo7Z0JxIw 08VfP5Sw3Szv75g+cHp41fqVmJGf7WI4Xitr9f7ksBCvVy80ZuLLjB2jz6tB5wN44gOwqy abN7p4ForUqZrBLN0bFhoYmtMfespsk= 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 9EADF20037; Thu, 9 Mar 2023 11:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1678360391; 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=MSk6Q5fXV5lgNPoon595PuYz0dxCHrt88iESPc6EpdI=; b=lF0QP81+QKvoOQpeTgIS8OuYXUwgoPjaJ5K5ZuviX/M/vhmhbbatmHhloTBMPt7pUSLB32 /+yCTqzD2huaZPmtnyXRtujsZXWpG3bYItFfpYYmsPHXpawLsT5fwHVTyI+MkMTpj5EOcT I5QmCvc+sLG68EuiMAJ0C84/1DmeuQo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1678360391; 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=MSk6Q5fXV5lgNPoon595PuYz0dxCHrt88iESPc6EpdI=; b=yKYa9OI8nzeEPmzRVx1GveVD6Yxc49Mh1tRy3l6C/KWuUi/LdCH1RQG0V03rxZhqphs1Fs HDCjKEqqNgJt48CQ== 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 7D5AE13A73; Thu, 9 Mar 2023 11:13:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YAsDHke/CWRiRwAAMHmgww (envelope-from ); Thu, 09 Mar 2023 11:13:11 +0000 From: Vlastimil Babka To: Andrew Morton Cc: "Liam R. Howlett" , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, maple-tree@lists.infradead.org, Vlastimil Babka Subject: [PATCH 05/10] mm/mmap/vma_merge: initialize mid and next in natural order Date: Thu, 9 Mar 2023 12:12:53 +0100 Message-Id: <20230309111258.24079-6-vbabka@suse.cz> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309111258.24079-1-vbabka@suse.cz> References: <20230309111258.24079-1-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Queue-Id: C733E14001E X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 497p4ux4rfdndc1mqifczfirdssoz5ni X-HE-Tag: 1678360392-216796 X-HE-Meta: U2FsdGVkX18h+7rESYiLKuf8JKXa9JFExL4HXujtNCO80EwLifmfkoNxXYZ5W9LqMF/X6hryqgfTrvYO+ceJO/tDavkSnmlD3jtxbZHphP97xfUAc4o6Wp0wH+lJ5niJ1DuAIBH4hLUApXRzEYkRkExY8AU8LkLJS9mCL7OPaHt2eFfmwaIVa1+HIcgZyM51JsHIdtsO4zEjPINaqN4cYBqb0r8xQybxbj3cphYmMjne8GjVPrfGhSqZOcQ5Z88HnM/R7h8VqQr6cvRsHBu032wxyLkvqwuD5feLnbCe11ND5z1L8S4Q5OowRiNbB+p0yyuXiuotDwD46mo7J49Ms/K9lnJ1Kw5dlkNENi0+vYCqruIdEFf9KyfPXfp7/x/bv3QWDV9zeZOYt6tBpmShf6ipPhE2rAGLPcRpvf27mimbTT2zM/z5gCseGdxxcRpU4fT/x2uO2SAxdhIelCi/uxWEKnkntzO7MxspwEYn4QT7iomPN8f41iuBbOmz61x8NCETOg3tc8OoXVE0SfvRLh+kKkwF+Ojjr7cSPE5Rx9X6+KAJ2rV49NPvU2S61BDKVe3Gisu9jTl8D4GgklSNnH5NNgZk/q/0Z8RueGYb/0+a8N/wd94txZyB6KNB/Q/wiJwI+576yYxDhhoUntgvtMWIoNQvIDJ2ilDvEoYRMg5cY5d3EpXewjgt/68LUX7WoWKy2VAg0ANsImd2YdjMfBmkyqIgsJJGDa6dzf2g2DtHhjgOiBQdzmmaBUwORlcg0VsNuP+HcgwVxOkgnCOFdw5axusszQ5ZDZp9mdHeCWOISMgJe52mviNv9ELcUQWQZu06ZGxhgm8Lkcrv2s/t24RaPtU0sarQQiHRAkHWfBTrrz0wxkEawkpz9qCgX94z5AwJjB/bSJuoZrc1QzZNlFnlqpxzOZCz1zBWkjVjZ5KIIjYW4oBGHaZ5Xim9I7xGvVDYH6EAXkE5boDSwZf 2P/DD1lU RavbJjD8Fnk2PHESfo7CPht42BTCbklFdbIxS3lYdm1QQgf7HvR+gKPhapdZkLBz8r9JgpcAomdtwQ55ZjH0ojFHkVOKEAlqyXRL309VPDUa34o+h/I5KKtIlwCCQmTbDp5UveoqYOcgZD2TMDgH1b6I5YcikjYJ9nHp6Ghu8QtF24Z293FJbVhuy4qTjrY1TG49PaN6ZlPiJSt5dXMF6FbJpzyFBF/5L+n7s6kA4xhTwFZZvqdY8s5aOfQ== 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 Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 420d6847c94c..be60b344e4b1 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);