Message ID | 20230109205336.3665937-26-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 65852C61DB3 for <linux-mm@archiver.kernel.org>; Mon, 9 Jan 2023 20:54:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04BB28E0014; Mon, 9 Jan 2023 15:54:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F3CDA8E0001; Mon, 9 Jan 2023 15:54:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDE2C8E0014; Mon, 9 Jan 2023 15:54:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CF8F48E0001 for <linux-mm@kvack.org>; Mon, 9 Jan 2023 15:54:46 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A7501140C38 for <linux-mm@kvack.org>; Mon, 9 Jan 2023 20:54:46 +0000 (UTC) X-FDA: 80336464572.09.62AD99D Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf16.hostedemail.com (Postfix) with ESMTP id 15898180005 for <linux-mm@kvack.org>; Mon, 9 Jan 2023 20:54:44 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="nfh/0wSN"; spf=pass (imf16.hostedemail.com: domain of 3FH-8YwYKCCkXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3FH-8YwYKCCkXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673297685; a=rsa-sha256; cv=none; b=GR2jWStuNhRdfriTvpm+qujse0AmM1HHNmvepntT/EeHrK8DQ5RHCpTkE7tfA2GroWXIuy XZw7jU9KqtMCCmcDwfvTAtg7RcQqTO/HH6TMj5LFpGy2GX9IcLgD0nLP89Cykrbm6ZQ8Ym O+wWjQf2YhRPDGdTiKWAxmbJlCt3lGk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="nfh/0wSN"; spf=pass (imf16.hostedemail.com: domain of 3FH-8YwYKCCkXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3FH-8YwYKCCkXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@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=1673297685; 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=89ITsq4nUiN8d4MMzUNaP/VKvoRvGlIDiLzssAyWMSw=; b=kbw/Y55RQpVoQrUTAL7I5z+2Nckmw4VJRaH4GC3J8uO7JoP3iHSZy1CJ0Y92IC266EHk1p FDEpTHNGbP8Ep2D5LjScgWa63pm1OK/ZnayNoRhQLTpPqfFWtaWVjXvNFySoNzVDQcsscu uHKHaoIIVawX79V0esEMPJIdhryWYhU= Received: by mail-yb1-f202.google.com with SMTP id w9-20020a05690210c900b007b20e8d0c99so10270520ybu.0 for <linux-mm@kvack.org>; Mon, 09 Jan 2023 12:54:44 -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=89ITsq4nUiN8d4MMzUNaP/VKvoRvGlIDiLzssAyWMSw=; b=nfh/0wSN7du3H+jbnftiNBYsH0L/ZzvAjrQDNKD6/Ux50j22Vuiz0S8HvVp3TvO1vo K/T56ndCuYOiwpC071dddEQYgomwd4Y1mEzWyHgdRsI4Zm5Szg4pGbhhjtZTIjjKwBZ2 DuLjlMuvIIQ0lWiW9Nfxk/1vqmTgUUR+Vpz2r/N+XxIUJS4L6MBvWuo91YhKUizAdsFD /Z7UYgJwWP6aH5EHzLl9AB9L/N1SliUIF0AbaZQSGUEgi4Q4Dc2tmxMGPV7cLiqwxdNW 0MiPjg6rJc2LN6ARMi2zMWyKxfOe4Y81VTcKlWoejCss5A49BpopZcqw0LB7HbZRjJwk DoGw== 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=89ITsq4nUiN8d4MMzUNaP/VKvoRvGlIDiLzssAyWMSw=; b=5r4aOVpuh2km018nNiz6b0BNfQUQKQuNeNJNf7blY9IIDD6ce/9UxNfflE6hFpigYk DkGHB4bikLvM95O3AMYglZL08pjnt9GEWAtQxMzBVyWMrIg8jKaOEiSvN/2a+lNYCUKr Nq6AGXCbXuzzaQRXncTLPZykrYLyzMMu+N0Xn6LTGrz4KUtyeaj6xXpPskf+6luHs/Zn G7rcd2oYyIaASEOWRa9xYLi3hb5rmlvX6rTeS/MXCavBkiZXU4ysPnarG4KWrEmNzU03 SArb1ulwVQUjO3LEeE1nTke9R+tz2baHtK0wnRBUwiWwyPFlZCSGfW4Wo3b5R/ulPXT/ m16w== X-Gm-Message-State: AFqh2kqQJ++PWgXOajfBx7705kqEFyMVcxiUg5TXailkYWyTib6nppu/ 7zeYDWPk6dRWwrCia1vJtaJUytJQOXI= X-Google-Smtp-Source: AMrXdXvWplK/QqycNgSSdeBDfganGdyEUrMbsmwVLuA4csVljoZeQRUCGyXX2t9p/6nnKr16T46cKc1FR2o= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:9393:6f7a:d410:55ca]) (user=surenb job=sendgmr) by 2002:a0d:eacb:0:b0:485:126c:3834 with SMTP id t194-20020a0deacb000000b00485126c3834mr6100451ywe.360.1673297684211; Mon, 09 Jan 2023 12:54:44 -0800 (PST) Date: Mon, 9 Jan 2023 12:53:20 -0800 In-Reply-To: <20230109205336.3665937-1-surenb@google.com> Mime-Version: 1.0 References: <20230109205336.3665937-1-surenb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109205336.3665937-26-surenb@google.com> Subject: [PATCH 25/41] 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, 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, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@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: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 15898180005 X-Stat-Signature: fee5ck33bds4rcgytap6hpybatbxjfnm X-HE-Tag: 1673297684-219156 X-HE-Meta: U2FsdGVkX19BwdB6uSBBDYSRh0c8ThIlIOZ3fFK8e1mXc0tB5fPaiMwG+lzBAmERinN5PbhnKWKQr5qsuYJCIThqlY7DgiKkt9I8okFan0lGX9NmXmVuhsihp+26VMTjN2Sw7t6B83ZdCHZBn+o7msHZqBRb5Leiv21D8vzMFh6uRXeNk8TK3LY1I4vwE5V18KyTyQxTH8mOjYo76Xx20+WzO5z41Dm8jpafF6ylHKWYc16plN0dxBYArnS6uc1ilLQ6hnAVq7GwOT14y8fK8fTKDobc+TDFFW4ahjQRmlZvnWYN6c93OOcewOD+tiufB9BckP+lLYzDBHLQuKXEpe8l0+bNV3m4gCL19TSUl8ILz6anALBpwMSQuC29fPCjIXUKutFLvQfuoTYQN+mqzK1soR2KXrf68093GAIs9pmZ0+BFU4u064/3JqAYnUx8PO0kcFEO/he8kl6LWGVwcMRodE0+09sq9njDR+VMQA5L0ywRx2hIP8AnkDTjfsNinwxhjRaur3RYg/aubob6+VVMfVvEseIgjDfWzebnDEKymQ8sdMImTy+SSwZIEnSx6mU+WksEJKl5mAT1ktpZdwSrLPJ9pCVrx/5AmIHgGJG4eNsTnRESu7jYf7kW4Yzz6XbjqbG7V7NjHNqI7KdkuLsWxV9CFdfOJYhlp6687NeRkbEyvSn0FVuWts8eD5WaQ1aB6Ab9HMCoite4h3D6+cuK0HuWMUgcnNuDxnLDPLPAjRFXaXZfrWRlZ1wJBlsEnqooLN2dmBP0RlITs5cj8Z47H9mVKLcjU4jnhRJoZLjVxZYM/At9N21R7Fnrp/Z/2Snj5b8uMW56tCIchu3QZ0CP7yWSOLObq6BWB7wVsHAeN2NbfE3tsj+TgLo/0kLSlRdsApejuDbLgyYoQ8oj523zSV6bSBFeLGlkX4mg9FSd+YTKUjPEmxNxFkl3DtCvwpdVXiIfA2qy8naH5mD qAqUhWm6 znt/eL3KVuH8wJAR7qzeUYl/0BdXlRyf6qsJyXgH2SpuDq8wmKVX4uZLlBxXh0VxegsNVJnDR1CiAjKvLUqL+sUnfli+PhLtM9fqWMMYqep4GoWphZ1g/HTdMBE+30cZAy7X3W8JVelDnlrJ2+6PPBPjze0ukZYu2FK1lYrb2vK8q2V5EjX61PdTdfUHeAfwZNSIxDYQ6FdXszNtNz/vhqdiwy5tJU/qAHTvyhkpQl2m4qwMalURhfwgMuYDXOrFNMG+kmHMyLhcuQc+LtssMLB28rcHliR1icK0hge/zk9oOl9OwXvoOtODykwb/C91khTkwEJib7AcsCs1hDB7T9GRadly8x1UptonLL8hhUdCRQ1c= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001531, 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 0d767ce043af..30c7d1c5206e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2461,11 +2461,13 @@ do_mas_align_munmap(struct ma_state *mas, 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_write_lock(next); downgrade = false; - else if (prev && (prev->vm_flags & VM_GROWSUP)) + } else if (prev && (prev->vm_flags & VM_GROWSUP)) { + vma_write_lock(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(-)