From patchwork Thu Sep 1 17:34:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12962976 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 E193FECAAD1 for ; Thu, 1 Sep 2022 17:35:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64A3D80020; Thu, 1 Sep 2022 13:35:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9838000D; Thu, 1 Sep 2022 13:35:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C16680020; Thu, 1 Sep 2022 13:35:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3F2548000D for ; Thu, 1 Sep 2022 13:35:49 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1D1AA1A06C9 for ; Thu, 1 Sep 2022 17:35:49 +0000 (UTC) X-FDA: 79864219218.27.1D2DF47 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf13.hostedemail.com (Postfix) with ESMTP id C45A82003F for ; Thu, 1 Sep 2022 17:35:48 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id v5-20020a2583c5000000b006964324be8cso4905834ybm.14 for ; Thu, 01 Sep 2022 10:35:48 -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=DiVLSVAVO410fRJcvWWuX+r6LjGy2i2DyacaHp6fzuc=; b=kNx38Jhqjx9XlmKxOVsRKukj17KeQAoUkvOgezSjJcI7qDa8s6siy6+ZCSn18LnVHi n4QLcTPTYnWQedOp2NOA065emr+I7/FhDV/20btA2UJprNGZCfJvY2fzU6JS3rffkIEf 2FurYAnF0+QmVLyL1XlOy/6eS9/B08Rzb+EHT4ihXLuAM0YGViLuLR9Pls5xzIb0RA++ peqVg5K5+yJOyniQSXXLxLw8N9e7jk4WJ8bD01w4ADM9IUXJZsw/A2NPWpCJiNE61osh 1/9xE4X1j0QNkz0GiHjK4YBUmosqgJkbBEuUlP/cGGRjR6eOLhrxcNhT+yoJZX8wCM9W ZvhQ== 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=DiVLSVAVO410fRJcvWWuX+r6LjGy2i2DyacaHp6fzuc=; b=TVaCbgEcPf59eiMo5kzAitzYWeG7oqTRmvqzPjB75OGumIWwI713wBbl3eu/ccplnI u33YoXlih1Ux1/Se9gqjZZDnIyF4rM6AYUvX8N8UpOB/Ou1FvsYAx0VOZi/ZWkKjmClb UeESbqJ2+ghZO9Y6nPqqjIQGxuqCpzUaWOZ/sdqAxzPmiUEgQ6CEcob55ueH5H+EOXpS qCv6BzHGw4rugnuhqZuYMzpthPs/k9ZKUNt996Pp+an7YcL+cZdUYPoNT7c1bK7vIOo8 ouK85YGRnnLYSWXk7j4XDwcf2REpKgq52O18YrUKbRaNTZLfG8R1UdcCxQr9tpuGE+4l BCqA== X-Gm-Message-State: ACgBeo37p0Mib08frzwzasJWX0UkkPYcp1hdtXD8gS6Y/a2IPGNFbzky I7XDFKBZxo/fcmgc+afr9W02cFafqOM= X-Google-Smtp-Source: AA6agR4qMG/7UuuiqhHhvohWNal3nFjDJKXC1X/Q7rlLCDCvl4ZyXaMMKRMmizmDLQF7LDsGfEt+/G6N4D4= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:1bfc:e7ee:6530:4449]) (user=surenb job=sendgmr) by 2002:a25:bf92:0:b0:695:8d8f:2af4 with SMTP id l18-20020a25bf92000000b006958d8f2af4mr20427159ybk.200.1662053748060; Thu, 01 Sep 2022 10:35:48 -0700 (PDT) Date: Thu, 1 Sep 2022 10:34:58 -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-11-surenb@google.com> Subject: [RFC PATCH RESEND 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@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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662053748; 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=DiVLSVAVO410fRJcvWWuX+r6LjGy2i2DyacaHp6fzuc=; b=0lMSBduz7p8CL0AsZe2HYvGa5D0dXhFAnlswkIAG7pbxs4JdFROdLmbz/JodgGJ2W1Usrc sCUZf/M+QB6MG0EwwK1a/nWK5go1ymOKoXIm5DOpr1IbVrEVnbBABnDzP7PNX0QhTdSMSz inN2zhDbGG9OYcrKL+BEgqRGoENXLnc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kNx38Jhq; spf=pass (imf13.hostedemail.com: domain of 3dO0QYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3dO0QYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662053748; a=rsa-sha256; cv=none; b=vw0lTgrQYD5qxp5CU7Z9CkztKMtA7OLzmODvthe4WNdg1sLEooKpNlW524cNslSfI+lPKW Hs5Mm+b7BWQdsNF50DrLv+zcyeBeEfT6kwX6ygraOsay0OUjT7ZL9ALgEk2mEUiVfmAa3L KT2oZnADb9x4bVkEgnZ7GNGu/FhDIvQ= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kNx38Jhq; spf=pass (imf13.hostedemail.com: domain of 3dO0QYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3dO0QYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam11 X-Stat-Signature: g1hr48bqwz85dn3dpg65okuspdcc6fnh X-Rspamd-Queue-Id: C45A82003F X-Rspam-User: X-HE-Tag: 1662053748-604543 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, 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