From patchwork Mon Aug 29 21:25:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12958434 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 CB0A0ECAAD2 for ; Mon, 29 Aug 2022 21:25:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63F1094000E; Mon, 29 Aug 2022 17:25:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C677940008; Mon, 29 Aug 2022 17:25:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4422394000E; Mon, 29 Aug 2022 17:25:56 -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 30ED7940008 for ; Mon, 29 Aug 2022 17:25:56 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1A0FBA046E for ; Mon, 29 Aug 2022 21:25:56 +0000 (UTC) X-FDA: 79853912712.31.AC92017 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf10.hostedemail.com (Postfix) with ESMTP id CB42BC0036 for ; Mon, 29 Aug 2022 21:25:55 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id g9-20020a17090a290900b001fd59cc2c14so3862554pjd.7 for ; Mon, 29 Aug 2022 14:25:55 -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; bh=nWFFKiz2JrcFJbZNC6h3WaeWKSGRlWYuGKA4mg+JUNY=; b=PCjrqm9NhycPwB3kYWPhGmirug2EAINieO21R1tkNllFgsambVeodQV2SWE+SPKnLk B35opb3MQlODsxNphVo3gt2yyCr1QpWXQKLcx1/vKzcN/4STqp6cRFJdHuKeBk+NsfTT tDOTylgaSdZ5nEY1ymyrW4L9evpwJBVsw8WgcZFUheAteEM8kYWXWY1xc4VUjrsXgS7n TvpEAgLiNbXgMlGNPVj+MFOM++dtX+BoFzGnROjLhFZB70sHOrsgtuWSCJIJNO8R1S+2 S3QUIvJ5IyCicdMqNDVbeJ892T5I6yDVEmvFVjdkZe2DnjLJIY2H8E2Qt303ElEJo4Tc HSMQ== 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; bh=nWFFKiz2JrcFJbZNC6h3WaeWKSGRlWYuGKA4mg+JUNY=; b=G12cInsR06LBnySAJn7F7/eqZ0rqEEQxX0V+IVVHGBpxJxKTRn8x+O4ZjO8/trIIe7 iTY1A4Z1ziXSEVeBFvDlWzzZNnQq4leUsqAt0eCS8tNp2mvrclpG1BCzZt5e5mxPdQe7 AWSgDAh/83LlT0ExP9dXAIjt3hTyrbE9f6VooBIbC5PWdaVn3KNb78II6GHxEuYDDTfL 4mbc+hvorAHTTQWGEVJbLA5q7oxnMqXOr0BxtKm1XCZE88px7JWyz6qibjee1FB/1KvC 1w0NvZ7mtJBfWwKfMp4kmgDDX85F7JDbApmmMEmlLX6gMVbDwRzUcV0QJKVINzElWdVt DdEA== X-Gm-Message-State: ACgBeo3B8aBLftzWDylqr75lc3Wg1/+s5NOqRbYb6AYrpVL7ODXrpDl9 GBEoGeMKkleNzqzT84T8Mtr99hSWoNE= X-Google-Smtp-Source: AA6agR4dglPLGzQSnoqHwxEZwo0Lk0EwUGiOTYsdKQuDkqIVlV54iwLYmhw7nxi8GDICS/TsbTVUTOyC/V4= X-Received: from surenb-spec.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e30]) (user=surenb job=sendgmr) by 2002:a17:90a:249:b0:1e0:a8a3:3c6c with SMTP id t9-20020a17090a024900b001e0a8a33c6cmr21107pje.0.1661808353487; Mon, 29 Aug 2022 14:25:53 -0700 (PDT) Date: Mon, 29 Aug 2022 21:25:13 +0000 In-Reply-To: <20220829212531.3184856-1-surenb@google.com> Mime-Version: 1.0 References: <20220829212531.3184856-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220829212531.3184856-11-surenb@google.com> Subject: [RFC PATCH 10/28] mm/mmap: mark VMAs as locked in vma_adjust 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@techsingularity.net, 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, riel@surriel.com, 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=1661808355; a=rsa-sha256; cv=none; b=MIxY3+9oqr1YlHXgXhIvTYrk9p/RajEMVmhuFqPf4KVj6CbIRo4s4eF0DV6vfl280dCQxH t/VnmJ3hUvh5d8yHAzxFoomqIPnGfoRxaOGNIDZwTyEEdLjndhyn3SaYsuG0UZezCB5Gm1 99OKqljvUR9ctJpA0Cqzu+G5AyUETks= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PCjrqm9N; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 34S4NYwYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=34S4NYwYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661808355; 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=nWFFKiz2JrcFJbZNC6h3WaeWKSGRlWYuGKA4mg+JUNY=; b=X6+y9MSeenMGUgBcKguErg8wO4zO30m1u/VkbG9XXauc5Qi6CYYI1tZfRZ0VtCJ664ERZ3 +bnD6if1pvk94Wdp45GCow8NjS1r9lDwhjiqJQ8CXfa03Svxc9x8na8aSfxGZS0FW7m6n5 id3eeCk4y4xG2aXrBPjEq6lNjeAdATw= X-Rspam-User: X-Rspamd-Queue-Id: CB42BC0036 X-Rspamd-Server: rspam12 X-Stat-Signature: qiaoyw7i8415c6xtd8m1p7jqzc6t5649 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PCjrqm9N; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 34S4NYwYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=34S4NYwYKCJIEGD09x2AA270.yA8749GJ-886Hwy6.AD2@flex--surenb.bounces.google.com X-HE-Tag: 1661808355-738806 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000280, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: vma_adjust modifies a VMA and possibly its neighbors. Mark them as locked before making the modifications. Signed-off-by: Suren Baghdasaryan --- mm/mmap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index f89c9b058105..ed58cf0689b2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -710,6 +710,10 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, long adjust_next = 0; int remove_next = 0; + vma_mark_locked(vma); + if (next) + vma_mark_locked(next); + if (next && !insert) { struct vm_area_struct *exporter = NULL, *importer = NULL; @@ -754,8 +758,11 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, * If next doesn't have anon_vma, import from vma after * next, if the vma overlaps with it. */ - if (remove_next == 2 && !next->anon_vma) + if (remove_next == 2 && !next->anon_vma) { exporter = next->vm_next; + if (exporter) + vma_mark_locked(exporter); + } } else if (end > next->vm_start) { /* @@ -931,6 +938,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, * "vma->vm_next" gap must be updated. */ next = vma->vm_next; + if (next) + vma_mark_locked(next); } else { /* * For the scope of the comment "next" and