From patchwork Thu Mar 9 11:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13167259 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 9CFB7C6FD1C for ; Thu, 9 Mar 2023 11:13:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2D2B280004; Thu, 9 Mar 2023 06:13:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB62C6B007B; 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 9725E6B0075; Thu, 9 Mar 2023 06:13:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4E0856B007B for ; Thu, 9 Mar 2023 06:13:15 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E95F80832 for ; Thu, 9 Mar 2023 11:13:15 +0000 (UTC) X-FDA: 80549098350.13.8A53EE4 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf12.hostedemail.com (Postfix) with ESMTP id 7EF1A40004 for ; Thu, 9 Mar 2023 11:13:12 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=vEtLBCb2; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=uW6jZY4O; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none 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=+3YUrWV7jfpXoA++JeKVk7hZ9f1CmC3d5xDMhvCnqQY=; b=P12ZqJBsfJoxmSXb0wURK1zYPuxjddFZdAVhbYGfzX6CkcSrmONIF0fvrMkogsSuipwDVy UjjqHneDdGyEZJ0f1Dg6rKt09xzoB0Z6XT6cgvyUlOmT69afjFRt8BFgfbvd11u4z4CnB7 QFcF5X3Bd9UFnkyWYcmXdcrzLjJBt3k= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=vEtLBCb2; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=uW6jZY4O; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678360393; a=rsa-sha256; cv=none; b=lSb+/OrIJPAQhjWtGmSpEJpwq3FBaL8CJWwvrdyfbidOYvouSRQS/AC2NMfn1A+6LN3D2K D0InvVhZwFmJrXu3229aHvmcH1A4AjFqDlAVXWGyzQTIdlylGLfSGuMpBkNAaNbZfey2vb KPGz6+Lq6tfXwziPd1zbmEXYkIW7K6k= 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-out1.suse.de (Postfix) with ESMTPS id 5D51921E8A; 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=+3YUrWV7jfpXoA++JeKVk7hZ9f1CmC3d5xDMhvCnqQY=; b=vEtLBCb2yry/emu/jQIc82ZS1qlwzsWUD3kbJjRDcSQH1Plr6grvNfNZcmXccfFFnXIVOJ KXC3aZGxY+Q4fR2CySOSWAp5CLIId9rmeDxY7aMapaHDH2HsOYxzL7hfo+3kQUVZBHKdau tbbQR77ynnrN30wYRBqIe6kqhTK7okQ= 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=+3YUrWV7jfpXoA++JeKVk7hZ9f1CmC3d5xDMhvCnqQY=; b=uW6jZY4OeymUbTM2/kEI4rtBKz9eeX37/5LcvI4Yc+ms/o0L55GgSWDvQw5rEuIxSmmxfT kLvXbh1WeGCFo0Dg== 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 3E55F13A73; 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 wFGoDke/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 03/10] mm/mmap/vma_merge: use the proper vma pointers in cases 1 and 6 Date: Thu, 9 Mar 2023 12:12:51 +0100 Message-Id: <20230309111258.24079-4-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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: odpdfhq43hqh43yqiqutoon6rpfie9qa X-Rspamd-Queue-Id: 7EF1A40004 X-HE-Tag: 1678360392-459967 X-HE-Meta: U2FsdGVkX1+DqXjagfxMfEV50viV/61uh8C0OaoOVZfsZ9Lx97i1GkNAGQ5m/vT00oO9f7JfYNhTp1jlXCrfhnU6O6IK0SSjnxWiDJaa6tOiLS7or0bNKRRRCR3IejCQyT4qqx3cmBg7FBWTVrefsi0k6kWs9AcP27HZo5gSk/9BSlZr6DyT4u3oyaoTNrW1EeEBTbM6A9SNSpeDjzjDsT8dWNp03iKfrxRvQ3J3G3CFMcR4MDrs3fV017QyC2l99c8djmdsNzMFrPKyYD6FY8CEJb+yT5d7WOv9BrHVweptTpvyWjspy3aB6GjFmhCtQnrqOW5zWrQYSSZ9cqk5mc0oZKFXrjJIomdiWE1Th3Y3haF4RIrIVoyji+scQR29j7QnELGvHpPYhueHMnf43A4DQaXKiZ+soLJxlQadwYNHUT0ZVAe5BarlB57pzZ28EwaqnTHpQbpda2MpaCkDTYSsBWiOscsK6zVtmaogE8cgXErqde7o0XEiwSzqYtKOzyj8Dz/BQzHwDzyVi3o5UfMw2HmOp9uOm88WFgV9dLrsMWp0Gnvi3Hr+D+m/5JrYW/v4XeNTvHj31n/UtGHWWYbe8/GT46cToHH0DKFgJ+rY3uRm92Aovd0zpTtSAk13MM2SN17FQPHMYoaXwOyMiuNaJp1h9PsXcCKVEs2zXT8/f46scY3/0y2g3tyykfP6Sxgf5rEk+AS817n/0NQWdvmWVvBzBBa/mvlWrR26tTuUR10MKxOdFPzNwU4MxVWl3sPJjoiuDaxt1T8DJmDu9oYWoOsK4WMDcYA7kGOUeSWq+xHqAGldNAMGUpG0YQBeJYnE6wkRBf6opTB/yA63AXypzi+PnzP8BCbXzOkdXK5DlO8zoMMMIrZFP1Jc6ZOcwm8z44vwkBZGXXj5PrafZI32OXupeb2tE19fPE3HfQrP1KqKm68Yv1LheOoJlOUwLZAA9njmGj4pCV7Jn1x 0xI+qeKR bi9Q9WLb22uRWM2KDXSMschn7vJdpvnSG2Gtn3GFKlNTs2Q71JRsf73yjlCLqBUw8nIMQfyYMHggz9Ztlqgu4cV49YwzRn8L8u/GgOjUbLuPyj2b+WgHQ9FJh1g5SXKKT9WLltqoHVoCIIziNGJaca2nSKvu1suoSJuzPzFKoK3klvb5+MbWDisdSjuWnzvlvIlb82cFfcJc1o+g3H7sXgrEmZvpXuKc1tIorx4lyqH0VGlQ3lbllk3QrJA== 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 Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1af4c9bc2c87..c33237b283c9 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 vmas */ 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 */