From patchwork Fri Feb 24 10:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151071 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 B8692C61DA3 for ; Fri, 24 Feb 2023 10:00:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572936B0078; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5238A6B0080; 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 32E2E6B0078; Fri, 24 Feb 2023 05:00:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0DD856B0074 for ; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C4511AC261 for ; Fri, 24 Feb 2023 10:00:44 +0000 (UTC) X-FDA: 80501741208.28.052B663 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf17.hostedemail.com (Postfix) with ESMTP id C4A9240013 for ; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Tr78MlmM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="vEOsnZ/8"; dmarc=none; spf=pass (imf17.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=q9S49Vc4wP4VJtPP7U3rbG14z7j2ldE6Nx08zIq8xuM=; b=U9MQWP4bIr+oRG2J5ZuaMVynOkEKHcmwNXLVQ6mIe93q8VG+8MvHAeY5AdQ2dOLTVLi/J/ /B9nT4Bs+/wVziv1ueNK92hjJQ6Culggd+AYuqIlY7AIF64iOgREC73WSnuxKZgFEn69q/ 96ftPVj0gLmC0MRxtNyhMDR+mdmUOU8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Tr78MlmM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="vEOsnZ/8"; dmarc=none; spf=pass (imf17.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=LFvIT9lbhdN9Yzk6wPYq251U2xmLD5TECgowvI6bCYF7mxyhMmTTxpC95ZJLvUWP0FkOq0 vqA6tw4fOn3XzMkqFpbqHP8SGjA9Spi+JyeLZz/1cRVvGm6aqhBlpqBy0MxI+OtbQ6sJRN VKfM+RGrkqdB+/FaYpFxWEk3pOkGbwM= 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 4F92520F48; 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=q9S49Vc4wP4VJtPP7U3rbG14z7j2ldE6Nx08zIq8xuM=; b=Tr78MlmMX0kPXukyljCLGjQEOsVHnL+81aPOiUFNTmWYCtN1zBTbSUjhZHB9ftqgxh6RXx 1d0/JvrSAVchiVzVVqY7LrlbCuIfM7hCo7YET2cmVgKdBOi5Mit9xnCwUOptxBQxpHYzO7 lJ5n7/gPoks9SvnG4gspGm5J7AV8Jeg= 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=q9S49Vc4wP4VJtPP7U3rbG14z7j2ldE6Nx08zIq8xuM=; b=vEOsnZ/8cVcvIWVnPLmyKr8eHtE0LGR1ZfQgvL9eEMW+pVrH2LB/t9GOljgkH4mRCNZsPk eHM11z3C2OMk8TDA== 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 364B613246; 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 OMR0DMmK+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 02/11] mm/mmap/vma_merge: use only primary pointers for preparing merge Date: Fri, 24 Feb 2023 11:00:13 +0100 Message-Id: <20230224100022.11268-3-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C4A9240013 X-Stat-Signature: qcdwnrwrf3c47s7fuzsxg58conygq5uj X-HE-Tag: 1677232842-57093 X-HE-Meta: U2FsdGVkX19P5v8+ONBhLiBsMzwcDunCho34YBkeHe4PMnUI81ZlbrESjFxewk3VEOASKK7GzMFNvw+MrKdOq/oMBu+BuOlh1wrhVhFcR5anr8BAnegrsWSv/vzQr0LR67v+Zx/5b+QyNPB8tQEwBDot1rM22kaeTe/0JmGQHI6QVsuoNyhn5rDHAAm/TvfAs8hS3POd4OZTx1H6NhZvtO4vN8/ZjZcptJC6GHEABIHdnbOYG16GMe/dfkVuc5+h19RsFN15fXy+l0e6isawi8q3jGz0x0JTNUAoIgTJCWy9plgCuX6cM2W5DcDLJ34gVYi+fFBd72vqmcerUQHRKpEqh5N6pbvygs9fS/VRUhz/KKg5oAiqjj90FeAxOmJqaNHZq+BIkelts7t11DPE+q6ghjTEP+YG7tWWQ+15A0ICaXMwwyJoBkYmLLyuvweRTmZMz9PsRBtzzW9OMsIGSAAUESsmTqPTdUuh2pd5XMnYRiUP/hCO0i/SjDFuLFqYAEZqUHBXEfASXvBzAyqHHcWBHnXCzzC8pnaF7yr1Vu+A1jvZkSggGvuO6L4dJWEgSp+U1mct/5x0GZENHjKw85Xy0CVy3jmOqJyFgxhHFJQh/+lbqDwWUaesvvYOllmygmyJcSVOhLcIkMKtuTT4Jynz4wurjD7gZ+FU/Zuur4S3y8SHfcLOXaKN6Q7aFnp5zMkQ6CRZYAcX3RwMOCaLgbLNzNX53pGy2trwlNYTjJ3J/6z0xoHI28dBvoZPMAJYl40OxlKAGtAjvIf3mel2XIPBgdQIXFY0ZUQwY/ACrCE5wmLHir9XjUxmt4lE1ys52oHU5D44TniAsbO3L86naCey4kBYENiIw+OfdGQi9M0IYCUhAfdaF4dpQxGLVhiS4IqlzTT4EdPEu2fKLFwdPIlk9YB9vmVAe8B/kp5ISgiDDUIVNqKwbtNgeEgDkiwbjORZ2RmUahkQNXLs2MY sOiCLhZH hsRkOPSKGd18uMsIaho57nN+NjLTHpGQ9NR60f6QNQjvKhhTmSWjEe3wJ07d6N4RdaAdi3ZtVUYT+ulFmN57rOENTVU5y/Sz4dnKyNVDVo/7mLolOVEni3mIdPRlJp26YJ4XK6/t39BCXCiog9OmS+liiMnrJDN4ti5cKWdkaTnIT0ZqdKLffqRb4yPPhHRiqJH74ezdo8rEHv6jeZ6DtyjPckIFTnDJ3PVyXOBxe3zuHaY10wPiCrtdaLA== 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: In the merging preparation part of vma_merge(), some vma pointer variables are assigned for later execution of the merge, but also read from in the block itself. The code is easier follow and check against the cases diagram in the comment if the code reads only from the "primary" vma variables prev, mid, next instead. No functional change. Signed-off-by: Vlastimil Babka --- mm/mmap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 740b54be3ed4..0a8b052e3022 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -950,16 +950,16 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, is_mergeable_anon_vma(prev->anon_vma, next->anon_vma, NULL)) { remove = mid; /* case 1 */ vma_end = next->vm_end; - err = dup_anon_vma(res, remove); + err = dup_anon_vma(prev, mid); if (mid != next) { /* case 6 */ remove2 = next; - if (!remove->anon_vma) - err = dup_anon_vma(res, remove2); + if (!mid->anon_vma) + err = dup_anon_vma(prev, next); } } else if (merge_prev) { err = 0; /* case 2 */ if (mid && end > mid->vm_start) { - err = dup_anon_vma(res, mid); + err = dup_anon_vma(prev, mid); if (end == mid->vm_end) { /* case 7 */ remove = mid; } else { /* case 5 */ @@ -972,8 +972,8 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, if (prev && addr < prev->vm_end) { /* case 4 */ vma_end = addr; adjust = mid; - adj_next = -(vma->vm_end - addr); - err = dup_anon_vma(adjust, prev); + adj_next = -(prev->vm_end - addr); + err = dup_anon_vma(mid, prev); } else { vma = next; /* case 3 */ vma_start = addr; @@ -982,7 +982,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, err = 0; if (mid != next) { /* case 8 */ remove = mid; - err = dup_anon_vma(res, remove); + err = dup_anon_vma(next, mid); } } }