From patchwork Fri Feb 24 10:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151079 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 971DCC61DA3 for ; Fri, 24 Feb 2023 10:01:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD7236B0073; Fri, 24 Feb 2023 05:00:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98DAF6B0080; Fri, 24 Feb 2023 05:00:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 460436B0081; Fri, 24 Feb 2023 05:00:46 -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 E686E6B007E for ; Fri, 24 Feb 2023 05:00:45 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AC250AC258 for ; Fri, 24 Feb 2023 10:00:45 +0000 (UTC) X-FDA: 80501741250.11.48E3005 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf06.hostedemail.com (Postfix) with ESMTP id C682D180014 for ; Fri, 24 Feb 2023 10:00:43 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=p3ZE5uLw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="exyNXp/O"; spf=pass (imf06.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=1677232844; a=rsa-sha256; cv=none; b=fQQ1qGMmzHVFWdLO7/R60kPo98hX78uAkuM8yO6hZ9jhG+hunl5XA6hDqRcmDCpXyuC26s SxNd1Go6/RvWU0HTLeRVd+/uFYNFZKfDrgpAcWqvCMFy7l8W9mu3xkWjLeKa/9Whlvx8xb rn0ofjJG7XHcLmiLAqG0C7OrSRMvKvA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=p3ZE5uLw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="exyNXp/O"; spf=pass (imf06.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=1677232844; 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=Am3Z7D3PJEF75x3/HiQBrnXvVKIlV3/Qp4c3FogRta0=; b=git4jgtojWFCr3LkFcNcJKqanXKk9lAMGlvEDNt0WgQ28d57Q53+I7wzq3Kh83HsoFBUf9 L8eaE1QXwKzCjEcwWBAiRhXnx7L1IxtJQrvZo3iLM8ivD2enzdvsFX8m4LmEYBgytLKweS +bqs7htiibJFbOFreTPINq5iXawNdUk= 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 9D9CB60097; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677232842; 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=Am3Z7D3PJEF75x3/HiQBrnXvVKIlV3/Qp4c3FogRta0=; b=p3ZE5uLwEtk/cg7EnX+HE43e+C5B6rCtvsUtSKn7CxdBPlUfloNsqfqkQFJ5WiO4rEiuzB CiB36BoqS/AxKRsf+8lfBJrCPJsWYiHD17DJ2nHjh2Thr9gF1vXZgckXkVNO2twWML+bU+ lTrcHL3qGPcvWhSc4rpP5vsD4O3OOfk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677232842; 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=Am3Z7D3PJEF75x3/HiQBrnXvVKIlV3/Qp4c3FogRta0=; b=exyNXp/OrTDQL6j9v3BOeWryfghFBfYZcF4TfoMJZypVOqnpw+z96xZJyOKkpRbJ2pT2R2 zYGobN1KuemM3LAw== 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 8010B13A3C; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8O9WHsqK+GPeTgAAMHmgww (envelope-from ); Fri, 24 Feb 2023 10:00:42 +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 11/11] mm/mremap: simplify vma expansion again Date: Fri, 24 Feb 2023 11:00:22 +0100 Message-Id: <20230224100022.11268-12-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-Queue-Id: C682D180014 X-Rspamd-Server: rspam01 X-Stat-Signature: s5wrdag8q7gj958bbc5d6fq1xf1p4ng6 X-HE-Tag: 1677232843-55485 X-HE-Meta: U2FsdGVkX19LKTRoRAgZ5VIeU/p7qv6Z7pmWxK3DGMnLaRkKQrnfunzIQ5PbMOeaaLptSA1a3k2UyyHXkWRQwEjb2HrR+6QIpaVixi0xm2SSF7EegcbaH9apScf18Zow4b53AcdpWwe9HWLGL8OZNnPKObD6Kgugit5AS/uX7GIg0U5gbO/yLLBbLCYC2qg9JqcCkNmiH8TemdKQ/tsW/xVkIjnViC+ScWDDr5JXkejmK9fZwKjliZ30HcL3uf5GrCTbQ2by6KUNjbXG0vnDNwHGGRgCYG9o/GbkAw9Jiyje/aKyDq3Ugw3XpbtUOj8GYxAhZ0B6Dx6FvvVPt70cfwS0Zw1xPMj7m/PFdFTR+le5YOWy9A9024+dnFMeW5uUYuadL8ItPkIgW/Kptxomq3GKEpIvsTGQP79u+x8ZE3/l/CbiLL9EMnkeAUKVlIQCuvJkynHKX4BJOHOkKKHmW+k9e4h5nlUGCSWepo4pjx+6tEcsx3cdymZDN/22O9cdrYpb4dZregUhpe898zGyICYYesxhKiNuMgqzJM752Z37rSzX6lvRt40tUPY3oONyOgBKNKsNwqNT13VovdZBQRIuUa7wxd7YnTdD57sQEsyhXICzUq6edGjg4p4S/NfCvTQDCH7fx1fc7sjIthpWpSzBFkeuRXw7D/7Y/Vue/IYhhdX15CVF4A42FZEl3WCEVJ5dynq6nbUbQfwKgV4M/kgEPk3hsLaDeoLxz58Hil9cqQN5jZ0jYoyQhTPoiAh0CdszVrPFxOPi7+15Tq3gW7qjkvEvCVBcGGYpEs4dH3STVogRkooPaX/7IybXvEMNMO3wLH22MM/wOrnqQVe4hnlzPVsQ4WUx0aRLhbvSoP3G6gmkEjO6SeIKRVqHnrDP205v0JxQguKE2RMd8p1J5ii0d5GSq5L1xBU6ZGzmt0FVSg7Fm7PbN0auKO+/AIN2vEgT0hwxpDmKwJPxTyg lVqaDzL6 dweLE1Gs/U3AekWFXrbW+cOrJzzUpro9pavOnHVmjWO705Wv9q/6e2Y0UKbKPsCZdPabPyOmWgstFqiMm3dHJcWTIVZyGw2AZB1o2dgLDzMEoAnTJT2TM8IbRiKWcrBb2M/n11tm6LR0VbuLnpW4LMyfyj9XKSGykWcy2cZtf/kQR/0peQwMtZeIIlxrsn9SqF2O4Yrd5cHyiufY= 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: This effectively reverts d014cd7c1c35 ("mm, mremap: fix mremap() expanding for vma's with vm_ops->close()"). After the recent changes, vma_merge() is able to handle the expansion properly even when the vma being expanded has a vm_ops->close operation, so we don't need to special case it anymore. Signed-off-by: Vlastimil Babka --- mm/mremap.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/mm/mremap.c b/mm/mremap.c index 411a85682b58..65f5b545601e 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -1040,23 +1040,11 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, * vma (expand operation itself) and possibly also with * the next vma if it becomes adjacent to the expanded * vma and otherwise compatible. - * - * However, vma_merge() can currently fail due to - * is_mergeable_vma() check for vm_ops->close (see the - * comment there). Yet this should not prevent vma - * expanding, so perform a simple expand for such vma. - * Ideally the check for close op should be only done - * when a vma would be actually removed due to a merge. */ - if (!vma->vm_ops || !vma->vm_ops->close) { - vma = vma_merge(&vmi, mm, vma, extension_start, - extension_end, vma->vm_flags, vma->anon_vma, - vma->vm_file, extension_pgoff, vma_policy(vma), - vma->vm_userfaultfd_ctx, anon_vma_name(vma)); - } else if (vma_expand(&vmi, vma, vma->vm_start, - addr + new_len, vma->vm_pgoff, NULL)) { - vma = NULL; - } + vma = vma_merge(&vmi, mm, vma, extension_start, + extension_end, vma->vm_flags, vma->anon_vma, + vma->vm_file, extension_pgoff, vma_policy(vma), + vma->vm_userfaultfd_ctx, anon_vma_name(vma)); if (!vma) { vm_unacct_memory(pages); ret = -ENOMEM;