From patchwork Thu Mar 9 11:12:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13167263 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 435AEC61DA4 for ; Thu, 9 Mar 2023 11:13:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6D026B0075; Thu, 9 Mar 2023 06:13:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD18A6B007D; Thu, 9 Mar 2023 06:13:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 700AD280003; Thu, 9 Mar 2023 06:13:16 -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 4149B6B0075 for ; Thu, 9 Mar 2023 06:13:16 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F252BA0FAF for ; Thu, 9 Mar 2023 11:13:15 +0000 (UTC) X-FDA: 80549098350.08.655B929 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf18.hostedemail.com (Postfix) with ESMTP id 023041C000D for ; Thu, 9 Mar 2023 11:13:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Mlm8A4Ho; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KJEXsfOB; spf=pass (imf18.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678360394; a=rsa-sha256; cv=none; b=75ZWU/Q/MVuxz83gRWhWV5IKdvprXeKLrv14sIzr902k3Jj1coB84a9GQngzBKqLGeNIoo cBOenLfJM4rmubJkyfwtnbeS3Ae2tWDnhGIrd9iXmxRWz8YpfDigGmxhZsjgbvwTk2aHNB BdLQKT02IgneVkR+E62Exq7cZKgBEU4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Mlm8A4Ho; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KJEXsfOB; spf=pass (imf18.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 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=1678360394; 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=KigtQf/dsJMkRBadC8WpaYcqiZqHunrKYz7Mr1969mpyXXjHizEPBmwrKUcPQR09o+pKFp NKYp4dxHTkiFvPXJ3vI5b77cD0DHPWIDEERUnhpSB0j6vBl5XDag6JyaJqYm6WmU3WPFim qtHt/SwxneFswWVFi36uuwy7i4doXQw= 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 1E47C20036; 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=q9S49Vc4wP4VJtPP7U3rbG14z7j2ldE6Nx08zIq8xuM=; b=Mlm8A4HoqAH0hJcmIH7nkeq7Ena0KY5bDzJYjrppMfaDBbBA3WohkCm9JIIgswP2JrYIvo zNTW4ebhcCAJOcnFqxgBVFKAYXWUz3I4R0UU5OTZYPI1D/0Rllmax+6SsLOiWp4rvMpYLW wBWINPA6bXrywVw+WjfS23ZYMKflGJ0= 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=q9S49Vc4wP4VJtPP7U3rbG14z7j2ldE6Nx08zIq8xuM=; b=KJEXsfOBSotb9dP5aHuNoEqWsFqw2hDjbbgnBUqsAQxTVJXXmvPoLo19GujxjABiZmRJoR Jf7IWKTG6XnAJ8AQ== 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 F1C0A13A73; Thu, 9 Mar 2023 11:13:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MPmCOka/CWRiRwAAMHmgww (envelope-from ); Thu, 09 Mar 2023 11:13:10 +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 01/10] mm/mmap/vma_merge: use only primary pointers for preparing merge Date: Thu, 9 Mar 2023 12:12:49 +0100 Message-Id: <20230309111258.24079-2-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-Queue-Id: 023041C000D X-Rspamd-Server: rspam01 X-Stat-Signature: i1et4nbcz6r38qrq8md9uwk9x94mibus X-HE-Tag: 1678360393-131904 X-HE-Meta: U2FsdGVkX19mFAN+44bRWlHistXmL/+PIV/XUCxmc+SoNDWL/NQlMcAMwJtjB3ZGAg71AwIJTqx4mXKek6ymnHsbLWPMh91sKC00Vgv1EktZAKHVIi8WPbhMnmXp8F2+daYxVR3UQRA9e0QvdvR1X13PJpTXshpqYlwEZcVlVlenGZGILKATlgC6qlFF8bbSzlZsLxVOkMKGT7Qxe2KEAs4kP6KYCKq1+O2Q2U2bek8yXGXRFhnt9MEcPhn+jVWqSOUtPhNKtgxLbdQ/LXWxq7FagxED83qtYUS4cfgFwHX1x0WSTUgfqvlEjAj+dj5xNSgiuDRFzd44Mv22Pgh+9p7KmZuIKV0YmUSsje/qGVONEwo4zqJ2ex2T+hx9hPyzbxrv4pf5EnJpLnq8jd2i+DDtj5mQMKZX1ZAN2Hv3KqA2/CArFNPEytu5LunQWJ6tofeROMGNYwK+lYdll4b64h5EiDUniaYtIFSXNpHyjAO0vYnaB0uFxZ9yJ+1kjJOLwELP4ppx8pe9huk9c9I2S2TlXB0T+72QiMwvWhkxeUeZkm2M/a0lD55mFnj88vmFHSOCsvjvOTjEDkt9GCOAtWEauLw7WwNjUSor9aZ3nhWHJA65NkB0n3TWK/dcSyEuIt7z8/USPNGiRM0k5W3C2WercKaq0P536fj4aqDZScwgvt3FAsbVkQtYuLuasuwrZExb4LOdCyNjN8JA40UULBxIF2iAh+cl81TWy26DKw5QCZ8VicSzlzomvOUEPEc3W3eQGgDEetkYskWHhfq2RvhLA+wAMlL0qlxJp/mOsslDt1pMUNEBGppOCLrqc1NYrrOGHzjVVR3rGhE531Z1XY9iJquOFe5VRU/zBx9k+ODRVf7OLCLlsSoEn65SuBiPU+OZ5LwdcytHzayRxt4jVS9FhT8OUY5y+zgF2dTYvoVEzsnP1cre1Bwm0L66JQzB3dW6kz/YM4AwBhZ1jOW PebeKw64 ax/2uUjZnV4mKLd89YiGa91E+YQX0MzrmHgKj6F7YCvL/aQ5SB7BuJlMrHTAGs932TrIhv9eV1HOoN/xbAis03cWGX9ib2Qa0jBQ6Mu0LGpuJICtdQnJrWLH34a6aXPZQL8dsdCuydd0JHALchHzvZu2E3CIe30/Bqk3z1diKldIVj432LrWZJoSreydMxC+Takxe+boYJhKBy/dXbRXA7IF0lDN1cf6JfLToEUnBgZRsslOvGo053fJ5dw== 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 Reviewed-by: Lorenzo Stoakes --- 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); } } }