From patchwork Thu Sep 1 17:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12962978 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 AB8ECECAAD1 for ; Thu, 1 Sep 2022 17:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C33880022; Thu, 1 Sep 2022 13:35:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 472AE8000D; Thu, 1 Sep 2022 13:35:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3617180022; Thu, 1 Sep 2022 13:35:54 -0400 (EDT) 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 286798000D for ; Thu, 1 Sep 2022 13:35:54 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0A71AC105A for ; Thu, 1 Sep 2022 17:35:54 +0000 (UTC) X-FDA: 79864219428.04.7C5C447 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf14.hostedemail.com (Postfix) with ESMTP id ACA2910003F for ; Thu, 1 Sep 2022 17:35:53 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-33dc888dc62so234880237b3.4 for ; Thu, 01 Sep 2022 10:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=SOzt98PYJdog9tZtODUdaF02HJMaRj5G7nUIc+/7MKg=; b=kTPvKd0Pj/2ICi2JaJbj4mvw83rGSI8D/7SpSALxOaZxZxYULx54dkMykzJllj/oUS acc8cAwohzpv9TG/117+M7kDarZ4pbcDRJw9kbqISJMHllJVQJpNPTnmGZHaFtdhW7jV te5Y1eTVCGFOLeMRtGhakQSv/C95dQTatvR3jNPFepOpi9BM4A2IDo4sHrk/Ld/IusAA C91XyLoa1Kj543iPIZk7cC0y8cEUyAun26iVaV/jukaSDh0nNNy3USNMwmiwPC/u6rrR uYxoBw75emQZr0TAylDwoEOSkfchxb9rhKIYoM9w58cv+ILGWIFbRnVoqe89UuzvgGW7 /7mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=SOzt98PYJdog9tZtODUdaF02HJMaRj5G7nUIc+/7MKg=; b=jQu+ld/KFOrNOGb20BFT4YXnvN9XjMiW5yI3BV4mZBYpGFGLG02KN0XJrzPHQtQLay bo48YS+V9hJ4tiqjXBrmWso1GmA2WwKCC5XwaAiDJT49ovBT+xezUDqpg9nGjQHo0SzE Or6Sxutt3MTg/fF2WEV2nzE63LNcz8QVHCW6V/Ujcw3YAqvzXlB3/jCaQWZX82jAmBfg ZmuoGcrKVyEhg/qZkycdT712kxw1u+xiskc3WMFDj5joEK8ib/a27jFcCaZoLdSjpavT k2BbBEv03x/aYscZjkZryzBC4tRgQ1Y6qhXEpRSoto/38EOZ1yaVSEc5b4hDrNg+EQD9 d6FQ== X-Gm-Message-State: ACgBeo2r29aN4I2aY5alHpUFza82upx78OqsjaKXVU4msC+qwTrGPhWb hEtrKZJxHJunT/trISF70QzZ96Sost4= X-Google-Smtp-Source: AA6agR6YY4L9oqUniRiEloavxF9b7QDLSzaw7mgfeu4Gq//fIM/XBjFxGsDu3HVa5YMmDCpCvrS70nu4RUs= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:1bfc:e7ee:6530:4449]) (user=surenb job=sendgmr) by 2002:a25:3746:0:b0:69b:a100:521f with SMTP id e67-20020a253746000000b0069ba100521fmr16650279yba.135.1662053753176; Thu, 01 Sep 2022 10:35:53 -0700 (PDT) Date: Thu, 1 Sep 2022 10:35:00 -0700 In-Reply-To: <20220901173516.702122-1-surenb@google.com> Mime-Version: 1.0 References: <20220901173516.702122-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220901173516.702122-13-surenb@google.com> Subject: [RFC PATCH RESEND 12/28] mm/mremap: mark VMA as locked while remapping it to a new address range From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, surenb@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662053753; a=rsa-sha256; cv=none; b=Ej0gWGwMVfLezhXw2e1DqRk/qnRu+5/QU2NaipDDncVgic+Qgs36IBTucFCuOa6bSh8m+L dVGl7No0Jwm8NhPjL2TrJ1r4o3jMY/btJvVA0UNrRHp4Or2RtWr1CrpcUrA2CHUv0AvrxB qpkkTbdIvPTTvIoVg3ZqSk8t0ZXJ9ts= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kTPvKd0P; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3ee0QYwYKCLYoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3ee0QYwYKCLYoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662053753; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SOzt98PYJdog9tZtODUdaF02HJMaRj5G7nUIc+/7MKg=; b=fiW1Zgn+m0pRKNV0J9XUjryXmcClH7b2L3J8fBbZFvd+TBk2Ze2HhooERzcVQ3B3SFB9gq jxoXf6dykbhjxwck00QDvJJLz2nFtLTLTRvIjUQkhiwJ1zdNujlxT6vuFhhNyBIP7kiA7p JjvCXdRrdDH37lFQzEpd7iddmmnijAk= X-Stat-Signature: jb5rscw4spceadqwymc75itwnr357jr7 X-Rspamd-Queue-Id: ACA2910003F X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kTPvKd0P; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3ee0QYwYKCLYoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3ee0QYwYKCLYoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com X-Rspamd-Server: rspam08 X-HE-Tag: 1662053753-976812 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Mark VMA as locked before copying it and when copy_vma produces a new VMA. Signed-off-by: Suren Baghdasaryan Reviewed-by: Laurent Dufour --- mm/mmap.c | 1 + mm/mremap.c | 1 + 2 files changed, 2 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index ade3909c89b4..121544fd90de 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3248,6 +3248,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, get_file(new_vma->vm_file); if (new_vma->vm_ops && new_vma->vm_ops->open) new_vma->vm_ops->open(new_vma); + vma_mark_locked(new_vma); vma_link(mm, new_vma, prev, rb_link, rb_parent); *need_rmap_locks = false; } diff --git a/mm/mremap.c b/mm/mremap.c index b522cd0259a0..bdbf96254e43 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -620,6 +620,7 @@ static unsigned long move_vma(struct vm_area_struct *vma, return -ENOMEM; } + vma_mark_locked(vma); new_pgoff = vma->vm_pgoff + ((old_addr - vma->vm_start) >> PAGE_SHIFT); new_vma = copy_vma(&vma, new_addr, new_len, new_pgoff, &need_rmap_locks);