From patchwork Thu Mar 9 11:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13167264 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 A46DFC6FD1C for ; Thu, 9 Mar 2023 11:13:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 160706B0083; Thu, 9 Mar 2023 06:13:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0240F6B0081; Thu, 9 Mar 2023 06:13:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB75F280003; Thu, 9 Mar 2023 06:13:17 -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 B90196B007D for ; Thu, 9 Mar 2023 06:13:17 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 77196A75A8 for ; Thu, 9 Mar 2023 11:13:17 +0000 (UTC) X-FDA: 80549098434.22.2ABAE07 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf17.hostedemail.com (Postfix) with ESMTP id 8603840012 for ; Thu, 9 Mar 2023 11:13:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IN9yYJDP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=hsyPFizF; 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=1678360395; 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=kFkbSRXrAhZV5Ie/p7ZI9awUzdtpDa6stald7mk9vEjxb1B/THCuOiq3kPU7DK2stK8NZX LDCgKoB01JxPmk0ivX2DzsAzOz2ndj4dmLwog+Q/4lNmLZRvxZhSzhECTUJJP2mjD7cYx0 RXFb9gDwMCNlbkixScYnW+nGZfHOMAU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IN9yYJDP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=hsyPFizF; 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=1678360395; a=rsa-sha256; cv=none; b=QizU15vjTOgBL7FHu5FKAqCeErkNj34DQJEpto9u4taPKbaIl7CEb4yXdfYTQ+IInoR3bq gDh2UKOxh5OVHDB5AHP9GFSVJm2r/O/MOodC2Ocf82qA22iwmsPu7EZjHu2/LQVQ2AqNsj Q6WsiEqAHI8a4lV4obbf9STxdF+jmCA= 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 47ACB2003B; Thu, 9 Mar 2023 11:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1678360392; 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=IN9yYJDPpAsUzcK/lBOeD2OcF3abAzwQ1DWsa1jg7+7eKnFdayh/P6CMtsBy7OtrQm00nA +0vQ3fFLUakpP8Rn+BjzZ5fmS5nIOFNikGqmEYsrfsawuNGhaI1yOvLmxMGMeyqPH1PF3a nm4+jG513He9UWKRAiy73yO6m8P43sc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1678360392; 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=hsyPFizFKqJYnSdS3E6xpTXq9S6r1rJ5Jji3li+g88rTqmX7AeSbhzGXDyIih4Pl7bflMh GAWJAY6loxrLWZCw== 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 2AA711391B; Thu, 9 Mar 2023 11:13:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mBDLCUi/CWRiRwAAMHmgww (envelope-from ); Thu, 09 Mar 2023 11:13:12 +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 10/10] mm/mremap: simplify vma expansion again Date: Thu, 9 Mar 2023 12:12:58 +0100 Message-Id: <20230309111258.24079-11-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: rspam02 X-Rspamd-Queue-Id: 8603840012 X-Stat-Signature: t4qzxnfgmjpadjjomf3on3ibsc6nn7a3 X-HE-Tag: 1678360395-265368 X-HE-Meta: U2FsdGVkX18vjT3QjgkpPUauz9c3jN21dJgoEJgLFeIb3cND1Gjvbwxppn+VhARifWCkWAfZAYKYjhtG18faA7ohn8MkEWf+VjlFPoX2fgjRpyGjUOELjNqMt94u6frSXNc+sAso8skgXc8GP0Gs9i7WQe5wqY9HUdrOSYWJYf2xTls1IOxI4RHtkvYvCjTI56CtZxxHxiCy7k70x8FPYtt1ADSQGpy2CUL7aaSwTGIH39C8ZyTH7PGGrGNOJj43hk/3RNVylCL1cUEioIEd+AomtYXqazB1wHO9grKKqN5pH26uoI67PVlla78lvI2UZOP9YwonKDRRFtfgkgQp7dmenX4O1SIww2Zw6IakzSMngmwOvbB2op0kp0/vniKN2yM8a26T5tMnORlyYU/Pk72ZkoQLnAyhpiiauLL5W9Dbn2+e8ds/SXzO/5/kLPBCdvUUS4L+L1GOguYTFcwwyUgLbZCIsj8OSkX51mI5uq6ASEFdcUmH8FEI2qCxG8l694WhAaQrvlB7rYhhZFCas0CsCgqqCSmF+MZg0X5+Ay3RhK8J18ulepdE3CQ18Kad3uZjE2n1UGvoPA/9HgLEejtTuYDcOOxkvwh1vQ0XhB53qzZyZ781YzZg+QG0Vkv6qaLhQfJ2vhUa1V40IG77jhB5AFlTGxTmMvRToupzpkOohFKe0hb/BNau+A/5YB+42JxCb+JC51hJL4ijDT4XyGbF3779Qyu4A/oBk6rMkhukpldnQptlbK2GgSCMBEl7/WyZjsY9xzOR4rptMK3Hp8z1XOj02NA0F92+VNpCCGCZYA2qYGMpzeV+aWcdAQZRviVM88r4wIF4getKiEjwlblANchWeCKNws0HtXk645PKTBVGpT6yaErfID4D4YMiH/ahwwE0snb2xYby/jRhnRA4EPx8/6j+gYA/q73i85qUi2IIvwoqOxINWJsvMT9DTiVM3QHwij7IZS2leXQ 6ur2b5Oo PwyLA504HJ00A5yHUGD0xFKBUyvRwTRJ7BIPXsjIOQPrGKRmyFXRBRLM/bZsdcxJ6o3q8vKw3LQJJW/rVA57Juz2GrYYY2VA0S++9jNdJayI5RRw20IRpRBAHuVGV8pw6kpdXJ3Qt4sj3MLaXcXFL52f/SlR2L7TdMOMQCZt7sBfa0+9iuUYjB19j12x39ncpLPUi8ptfyB/qU6g= 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 Reviewed-by: Lorenzo Stoakes --- 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;