From patchwork Fri Feb 24 10:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151072 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 C3E16C677F1 for ; Fri, 24 Feb 2023 10:00:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8815A6B0074; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 831B86B0073; Fri, 24 Feb 2023 05:00:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 571916B0073; Fri, 24 Feb 2023 05:00:45 -0500 (EST) 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 39B396B0073 for ; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0557C1217EE for ; Fri, 24 Feb 2023 10:00:44 +0000 (UTC) X-FDA: 80501741250.23.6B0A702 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf05.hostedemail.com (Postfix) with ESMTP id DC498100013 for ; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=3SY5VXph; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/jIAtMOp"; dmarc=none; spf=pass (imf05.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=qDnc8EEjpBsvOiKhZLRnNlYD59HvUD8m9uXQyW8ks/U=; b=lPdolvJRm1IK6kES3f1gSIdzjM/zZNMRD6gErR+RMpq9yYf4uNA4gUB8fpLMZFG61r+ezc blXtAoqEuKgUVxeU+p+Dr3RadLKDm41bS9yUMd0A5xmmMJMrTQu4Bua1XygdmrTHof9YgY 2hjoG9YwKpgnG0c8kFw3Nz2vahr47XI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=3SY5VXph; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/jIAtMOp"; dmarc=none; spf=pass (imf05.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=d3IbqhXsWc+ZSBGSniWp1BWvnRzIuEGXRvFFp07qKnZGTE3x+QxIcV+SnPO+K5yz/SF73Q xmsFhebY8aFhlWB9Ila2ZTsqPog3d625BVF9C13YaTTIoAi+4UJ+S7gdeWyyHKjXaVQ2vE dm1LwG03nmJxruk6oeX/fdBtYYHCfwM= 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 BC0165C9DD; Fri, 24 Feb 2023 10:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677232841; 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=qDnc8EEjpBsvOiKhZLRnNlYD59HvUD8m9uXQyW8ks/U=; b=3SY5VXphxPVip2cwgUzC6lOWoIxu1TXkew7APj+jPzBAf+IlC6a+bzrUBpg63peJcBGHgr cQFjIVUoPpBegCvEWaQsz64Y+C80k+5H8a8EqUuJnoxNEeuD8LnbyXtsDJb82TeOS1psl/ rgX7BNLG6B6ql4Gt/2iGE9eMUm/p2mI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677232841; 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=qDnc8EEjpBsvOiKhZLRnNlYD59HvUD8m9uXQyW8ks/U=; b=/jIAtMOp3EUMEalc7cG90G5k2mOZB7brQnDVETi/NY6CKBucBfOljhQr8Ndj1oWYSVgzl4 VsE7Pr3tVwvZdyAg== 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 6D09F13246; 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 iAsMGsmK+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 04/11] mm/mmap/vma_merge: use the proper vma pointers in cases 1 and 6 Date: Fri, 24 Feb 2023 11:00:15 +0100 Message-Id: <20230224100022.11268-5-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: DC498100013 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: sike8np4k3nqy5dq36tnse4pnpgdj8g5 X-HE-Tag: 1677232842-690266 X-HE-Meta: U2FsdGVkX18t19US4H2p4aqUlsKm3+/FRSS/xkC6kQcOT5zgKRoWvZ58y4PXKGBarcwfseLBCGavXCTkxePGKUGS5DTAzjArPTFT0KB4VDFbZswiNLUX0BvypsVdiRqn/SBD6X8zUbLiy5YYPvSQ5YjoqyBHSiCh9PsM26VdoFMyYjHYXskGoRmj6fK8/cZ+5TNvldb8uRiRNPgEfJjZPW22oyTxNgUFtMhQZid3WS1HuVHmR1X9x4gjr68AvOKhK13NIbGdmj3EMkH6zSPAke3Zovi9VltWjRHrulIsEUBFILEMYEVipAtF8MT5DIt31+8vZXn5s7u7BiuEPl9WPhpy4KI41lwN5+X0tH1Fi4K2+rOwlFHpY8HFwai9rlW5oX+0zhjyGbDSfOv1H3Rc0ixOEQmL8ObWILUdp+5itprzXj99Uk9/YzMox/rmim5LDqXcKTjIHXUJ6mt2a/e0n8lLWLYuAXlwjT2sAIVrsbqGRI4o2T+07QJ7qFY6zH4aNfgC8hwEuVUsaGObaTJC2Tua0aBbLs4PFMh4SqfuvYUffWETLCJLGOMr8mj3EMZJpRyhx9EfBJLIdV/7HdqmrCbkGCrS2cUtndKdX7Xyv7CWmZ62umM1FgRJZWAfZmGLQx+gHe7k8UZxMakYx/HFRbrDb80Pdeu3W7xu/GXkQAhBVR5CjNehoRK2k+lwujaTSB+Q26w0UmHnOLRqgfTYVkSV3rTBxz3s5Uzdp/4tQCjumjrYLYuJCPUyHIwaErYBcUyp3ofDf7b36ZJ0jSwVrlV30LH9RvymmqtWlyG8aNNhF8ufwy3qvDkTZmokKbYDobK8hSUUk2LjyAu2AjP+hqYM4IRYEX7jrg04lzsk2L7Q0BHcc8Tak2hDoyfplclGQjEtJhY0xRX1lzJa2+aZecj3xtNwCM9q//nTFWbzcWuskM0aImcpU6IVu3jAQgTxBWDe7BPh6UU49NYSLYX lzhSnZ40 WtbZ+gK7Y3hpYAIvEs2TFJju0SblNfCS/X2Y5Kd8mhzBIMOuJEx15C6P+1Qno02JiWP3UN72uAgjqTTN79PgiFStEbcpxQIHwc37KnNGgVyQOHrre3HM2ZAfNnbmdodcw993tpm8fNz8aTXDFrEHTE6J+w8wZRleTi9yMxbplHlNS69/zPxPh3imlwMwZQAWP+fn8RY0wuOg5N9Eibrxa9oFtvm5qvPRHft4OmT/dneLKKhR2COaA2oNSiw== 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: Case 1 is now shown in the comment as next vma being merged with prev, so use 'next' instead of 'mid'. In case 1 they both point to the same vma. As a consequence, in case 6, the dup_anon_vma() is now tried first on 'next' and then on 'mid', before it was the opposite order. This is not a functional change, as those two vma's cannnot have a different anon_vma, as that would have prevented the merging in the first place. Signed-off-by: Vlastimil Babka --- mm/mmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1af4c9bc2c87..704afa278a98 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -605,7 +605,7 @@ static inline void vma_complete(struct vma_prepare *vp, /* * In mprotect's case 6 (see comments on vma_merge), - * we must remove the one after next as well. + * we are removing both mid and next vma's */ if (vp->remove2) { vp->remove = vp->remove2; @@ -948,13 +948,14 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, /* Can we merge both the predecessor and the successor? */ if (merge_prev && merge_next && is_mergeable_anon_vma(prev->anon_vma, next->anon_vma, NULL)) { - remove = mid; /* case 1 */ + remove = next; /* case 1 */ vma_end = next->vm_end; - err = dup_anon_vma(prev, mid); + err = dup_anon_vma(prev, next); if (mid != next) { /* case 6 */ + remove = mid; remove2 = next; - if (!mid->anon_vma) - err = dup_anon_vma(prev, next); + if (!next->anon_vma) + err = dup_anon_vma(prev, mid); } } else if (merge_prev) { err = 0; /* case 2 */