Message ID | 20230127194110.533103-21-surenb@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 35A6AC38142 for <linux-mm@archiver.kernel.org>; Fri, 27 Jan 2023 19:42:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C027A6B009A; Fri, 27 Jan 2023 14:42:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB3126B009C; Fri, 27 Jan 2023 14:42:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2A666B009B; Fri, 27 Jan 2023 14:42:06 -0500 (EST) 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 8FA326B0099 for <linux-mm@kvack.org>; Fri, 27 Jan 2023 14:42:06 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 296CA1410D3 for <linux-mm@kvack.org>; Fri, 27 Jan 2023 19:42:06 +0000 (UTC) X-FDA: 80401599852.04.1B884D2 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf28.hostedemail.com (Postfix) with ESMTP id E16C9C0004 for <linux-mm@kvack.org>; Fri, 27 Jan 2023 19:42:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kcxorgjD; spf=pass (imf28.hostedemail.com: domain of 3CinUYwYKCNEFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3CinUYwYKCNEFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674848522; 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=1VGgj1TmnjNrGwceq1Y9mwtgHdomU/ZJ3zMBBp7twvM=; b=qJR3t697eTQeesYOysfl58+Y7eA1sKFDGZ4Qdexgsq8nwxaMnpWxM5xlcQWNzsHDbeDDy6 LK+fj5oS0MgV0pObQvu9bFEyvGVIggH8ZBqaY8J6+30i0MoOIDE40kiod5BROD5JTNI8Nc 5Fl6bx5SoGevQAAwVdkducXItU4mogM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kcxorgjD; spf=pass (imf28.hostedemail.com: domain of 3CinUYwYKCNEFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3CinUYwYKCNEFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674848522; a=rsa-sha256; cv=none; b=uFSzxfUWUO+VHhl3XUX8BTb5TYKXF/ReV4i8r7Xr72DzTUzuk1uoHOggfXZRjPsdpNb/aR 46NPPzt6gGzs24bUXDdIvxc1S4N/1MJtmdHSva+VVdqb4+xE1Wf+Z+RmMpyOsMJ1sgxf8J TP6xCricn4pNDEhganU2lk/jNyb0XrM= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-4ff7c6679f2so65762467b3.12 for <linux-mm@kvack.org>; Fri, 27 Jan 2023 11:42:02 -0800 (PST) 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:message-id:reply-to; bh=1VGgj1TmnjNrGwceq1Y9mwtgHdomU/ZJ3zMBBp7twvM=; b=kcxorgjDvieL4H0gsZ4o6ev4StdVYsVDA7GZVrIORQdjZKoFiGI1KoZQdzzvMshMrE snI0AzaYSvDLC9zEn2IBQumHO6CKLkrL/i3wJ9ueET6bm8oRn7QEPBX+BM7UODPO3hzZ U4MGRqXmViJMsS4HDNU6vnAmwplZNvnqe2D+qu3fGFBMwOJOM+QBc0aicDuQnfczJKX+ vPW/+j1Kiez+csRZc1jn4fVsV2fgBwTNZpRX4guJZVX8gsy3dFik2ggDGPcziixMOIIZ ZlSkjqSVG2I0FEWcD7z9JqxBzo/zAlN1m8/Qkt+nlr6qzU3SYltCmGn1Rp59psmpvaAD Fzjw== 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:message-id:reply-to; bh=1VGgj1TmnjNrGwceq1Y9mwtgHdomU/ZJ3zMBBp7twvM=; b=cBG3n7UeR+1WtIxXw9ZWLZDVj6qimQcGIsqLVvwhSKvZX16OFJ59nYsTwk24qUwM0P wTIT4sy1u4rfiaA4jIIEhzkRm6Wqb6ymrv+o7ub0fyE1HSPuBY3DpxOoy3mIOxlmV98t jNBSlBDuSSMACXBEvlRT68iRVPah1RBDlpS9mRg4cpnFVyfaxA+omaj7Y3LkqLPSyvJQ d+YmTGbfjbGYVa6DQtth6Gbpu9ej85Vc/eiybn+FNhQJZIbE6z/X3XOQ0AtNtqtcsPZ/ 4cEXjW3f8tiEp2EtVjWimv+uuejr85LqRaatiUQxFiM1dcC4kkbTv8gx/jIkaMBduPs4 CJqg== X-Gm-Message-State: AO0yUKXq7O/gG5OljyuxPBNVy7Ey+//BeRyeNggqtK6jDBD7wO1Nz+bV 4ujtbr+Ra33r6ZBTGSwmBZIBa05YZaM= X-Google-Smtp-Source: AK7set/jPsOwzlm+kUPz+CABbySieLCP3cL/8jypOFocWiEQOE8fcbH4Z91B+4ltIKP12TkxYenF+FhrAT0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:4e19:be9:c5d0:8483]) (user=surenb job=sendgmr) by 2002:a0d:cb8b:0:b0:50b:1b97:f19a with SMTP id n133-20020a0dcb8b000000b0050b1b97f19amr434148ywd.164.1674848522027; Fri, 27 Jan 2023 11:42:02 -0800 (PST) Date: Fri, 27 Jan 2023 11:40:57 -0800 In-Reply-To: <20230127194110.533103-1-surenb@google.com> Mime-Version: 1.0 References: <20230127194110.533103-1-surenb@google.com> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230127194110.533103-21-surenb@google.com> Subject: [PATCH v2 20/33] mm/mmap: write-lock adjacent VMAs if they can grow into unmapped area From: Suren Baghdasaryan <surenb@google.com> 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, paulmck@kernel.org, mingo@redhat.com, will@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, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com Content-Type: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astJrzRnpJsP006MOlPBsqVm+2Szt1unETJak7VlLtiBVUog bQ+w5nzq T89oUv2+JZ/2sy+R0RwG+SCDtdDUmWSC6xcK5wodWihCkQl5CIi600MZTwHkaN85yrN/pFLFgDfdlkNQi18PdH1koOY1qTgmgyx/aT+GAQUl/DMktW0msOOoOh5BqpNAhyngwlxbxDVcQHEhbZYiBLqwh1elCfRIjLg6AN4weihqKApsc+d7McwXfDI4MCvzgOFohnI50XvEa3Umf7KDTVN3Llap4Bwu2oDV4m0k+DYAGDJu4WsUEFD0Qxtj9N10VoBd+v6xB94OBCtDcYQXIeIdiTPmRH85uSq0qyhBGFuJPyOMqmlQRDcBjmijKEAgJohOEwm/TF4S0JeCS52fOOBYZ7fF1C5BXYZ23tgbvk5A9DGOCRTYd7NDAiBM1MGuValG5K3CoG8E9KTJWdBtkfpbIeBgv7YYVlfdPY27EWPpP+PzjPPmgJSnRVNJorIVPksTH4709avZ0m9MRhPmOx26lvlmDtRSFOOgboav0aGMtfPCQ2bMngJgWhmh9TQm94FQFm3+7RYeu1jG28TR/w7mP4QxHaNF/iQGcQQXBHE7tn3JdL1f/VmcFBfVinorIUelqh6BICXNZXWS/mkUtwdZ48Vk0iyft9MZ0JlfDleYdtt/c1edXhpxxUg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.011723, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Per-VMA locks
|
expand
|
diff --git a/mm/mmap.c b/mm/mmap.c index 57cb3a2ac9b1..3baf218836bb 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2399,11 +2399,13 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, * down_read(mmap_lock) and collide with the VMA we are about to unmap. */ if (downgrade) { - if (next && (next->vm_flags & VM_GROWSDOWN)) + if (next && (next->vm_flags & VM_GROWSDOWN)) { + vma_start_write(next); downgrade = false; - else if (prev && (prev->vm_flags & VM_GROWSUP)) + } else if (prev && (prev->vm_flags & VM_GROWSUP)) { + vma_start_write(prev); downgrade = false; - else + } else mmap_write_downgrade(mm); }
While unmapping VMAs, adjacent VMAs might be able to grow into the area being unmapped. In such cases write-lock adjacent VMAs to prevent this growth. Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- mm/mmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)