Message ID | 20230216051750.3125598-20-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 48741C636D7 for <linux-mm@archiver.kernel.org>; Thu, 16 Feb 2023 05:18:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D79476B0099; Thu, 16 Feb 2023 00:18:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D02A16B009A; Thu, 16 Feb 2023 00:18:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7C586B009B; Thu, 16 Feb 2023 00:18:43 -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 9E0F26B0099 for <linux-mm@kvack.org>; Thu, 16 Feb 2023 00:18:43 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7818214109C for <linux-mm@kvack.org>; Thu, 16 Feb 2023 05:18:43 +0000 (UTC) X-FDA: 80472000126.04.E733F80 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf09.hostedemail.com (Postfix) with ESMTP id BBA62140002 for <linux-mm@kvack.org>; Thu, 16 Feb 2023 05:18:41 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LRD+lTaX; spf=pass (imf09.hostedemail.com: domain of 3sLztYwYKCAcz1yluinvvnsl.jvtspu14-ttr2hjr.vyn@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3sLztYwYKCAcz1yluinvvnsl.jvtspu14-ttr2hjr.vyn@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=1676524721; 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=rL5PSjChr8wFTlKRWTO498bp0kCwADLZZe/SXHes2h8=; b=Wwtf00u8Up9VMd75jMxb9pArgD8TaxeUv7wkTYcHyVqdwQO8jX4uZt8PhlLRYBNkzwkEbd zZ3byL/Qi4LhxEhMKXq2pl39bb+1WXzxUSQXy2NE/vJeJNx/ekC58LNBXYUNhhpr+AHJky VZCADMfngvL7tm48JEos4Wc9u43nU0k= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LRD+lTaX; spf=pass (imf09.hostedemail.com: domain of 3sLztYwYKCAcz1yluinvvnsl.jvtspu14-ttr2hjr.vyn@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3sLztYwYKCAcz1yluinvvnsl.jvtspu14-ttr2hjr.vyn@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676524721; a=rsa-sha256; cv=none; b=YrsYou8IpG31YDRV9Ig1554BhPNGGW6gqwxA5yYEs2x7pOtmwNHLmm5MS9LTE0o4HY1smo +zLyM6Tm8v5KjF+kzLoBk5PIgmMTS/P8ggNf3ZkNG06cx5+CEr7qK64/0SZZMy2Wm2U7iH zuVfVBV+APEfIbgUqKRY0rXE19s3akU= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-4bdeb1bbeafso8699597b3.4 for <linux-mm@kvack.org>; Wed, 15 Feb 2023 21:18:41 -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=rL5PSjChr8wFTlKRWTO498bp0kCwADLZZe/SXHes2h8=; b=LRD+lTaXr6Pqw8LYMkej56Kfm91pJviFVpFaUDR17WEIFgUKOpU+ogLRfy6oidvw/F 4mOXwIhPJkh7gxaJzacQ5Q2xpA2MxMudctw4pQKYtuqshuSCMBeCw647b99z6JqUfMYU FnWI7aY3RIFvc0EuIZqwF4n5sAACqaxfMc5BUHOhpo7PrLkybX4Nw85DLStMxOu85Den S+x5aTXsnUr3Va/T4IBtQXPzTR4iMs6msv64zgKWL87HLYoK/sTJqZLT5fditOnzScG6 JUQkoM18jflZAeAGFMAkFQi7v0aeD9Evl42tB/J4ec9dW/Jbo4ktb05auTom3OB08iqz 18AA== 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=rL5PSjChr8wFTlKRWTO498bp0kCwADLZZe/SXHes2h8=; b=yRqZmJyMttUTzOWgXambDvqpZ4l0hoOlxXE3SDXdsvOpn4aD2HH2yHkL1wg0iAS5SZ pVq9Hw1j1MES3qI1zad0yJhBU3AC/j4xqDhaA3vE3cpgtK20spGAq3Hkol7C+MOW+Hvo rpkstc6OEMkDk5E01rSKEgLayVzHR47V5ys4W4xyOBOguBiDNrAniWLWrRRSJVlkMWzL 7euoi82QlXqR9Lix9rcSS38xBYT7cE6nAoAVM+2xn3+N8YNb+idM0Nmlwdc/k/8AgpdL BY9LgALXLBe76GN0pxz3suuziSLaZREyi0QycG6IIIDoIMFowLn4d4FQkwChIWdhiRQL 9ApA== X-Gm-Message-State: AO0yUKVafKolIHsNhITeYM6Yw/Cmqlpi/76Wlj2OESQha3/tTvbtE9wE 7/QJOqfZMPCJxnCYnOzPTKAOWxXxqW0= X-Google-Smtp-Source: AK7set+44y5aeQf1zuFNW05XeMWyuIDsdI+r8pPqkHzR/in6WRVQ9dwNjFzyqkfy6m3wNLuusOCyHSVO/GU= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:f781:d5ed:1806:6ebb]) (user=surenb job=sendgmr) by 2002:a0d:e506:0:b0:52e:c531:20b3 with SMTP id o6-20020a0de506000000b0052ec53120b3mr448676ywe.147.1676524720915; Wed, 15 Feb 2023 21:18:40 -0800 (PST) Date: Wed, 15 Feb 2023 21:17:34 -0800 In-Reply-To: <20230216051750.3125598-1-surenb@google.com> Mime-Version: 1.0 References: <20230216051750.3125598-1-surenb@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230216051750.3125598-20-surenb@google.com> Subject: [PATCH v3 19/35] mm: write-lock VMAs before removing them from VMA tree 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, chriscli@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, michalechner92@googlemail.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, Suren Baghdasaryan <surenb@google.com> Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BBA62140002 X-Stat-Signature: dh3anos38unxpn9gewzqpopg8z4hdice X-HE-Tag: 1676524721-788833 X-HE-Meta: U2FsdGVkX1/YUoGuDeKKm4fVTdvSDyVhKiJrUEg6prrtbJWSPb7hHD5cF6qeCbCU8WICfMw+kYl9eKcXgGeASFMNtUwnd6u66wdWWMt+q7UTXR+AJ+kNzmSZbnqlTVmgqHtBgkQmhfaHkDSpVuk35TltpKyUKJD1RMYYtv9jsCgORYcqUB3J8O9WeM+yQ64lSl9WBLQHJugy0kruSjqXcYHzfDnyRT36s2ozzNyYx7pWHA6Bk6TKdJKME7v2/B0ocfR5XI/muRETcgz1WXVAagqrlKhQCr2pLU423It454bkN0U+OtwvAXF+AOc1WI9SlAKXpn93QjiYPNRuIWcdal8ZkDiyzNahJZGzh3MYPPoereCli0/oAMapAQVmG4GVJDPj+IoC6NtsR4kGTVa5EQ0+ZsQ98Rrxi8N862ifRVegfFC2a623r1Mfe+5SIq6yHb+FgkhTDIw/HMfctl/JSRMrVWaYoFKz8EhLauQIbuqZjbsfKP2sKILYxX2Cf99zW33apo/NlTqM9um/Zx4IVdfGNUH8/WEmUtDOeiCZfHJSk/+C0Nu97E57vOiNirys7UgLwjO/MEBF5pnaKr81Tbw8zZHFMuljTFEJJcNAPrs0qrsbUX5Eoz1ewgI6Aa+tZimNN8gyp7Ggy8UWVk4zR6n5u7AvIkmTJDL5ah2k+XIR/wyDnQZ1qtalJBLgspKKqwWkKw2ieT8e9XgkU5+iVax4OszLRX75KjfosJYn1b8bjTUDZ49WDfkJ1SmxycIR76t6hdCuns1QVbqMyhxLO9lC54endpSKnqFO/OQXjaE/T8OecngAeGIjta1gDqxm+0lV6kJoMSJtHza0TEkeTfV0bj5o8oEwX4HxBhKeFvViMCBqyAgdTyi00faZKs3+2QLQJLEs33iHPDZj7uxn0w35WKIIgxx0KlLxFfw1xgZzPb2j7x0gt550Hrhfs3IDhDR103Q+iaUjK0tPX0y I17PMFUF FyFcj12BKRWPhl4mODuIO6Mg2X1Gc+ujCmrOFZHfw7xqO6PiZJ455zbUNrXFvE4e48qRS/ixKPUOKA182A41w6tpnMjMGmXmtsVBBsKDHmryQ16ie2WyDbR2vQLPHMHIwrLl5V1+GksoNDYba1AL1XF0Hxmc6PSeBkmQLnphGQzd9lP7m2pCossBORs94yCFUmGl2Mrzdp4LojVXTe551lCe/74pXzTGLaa3ziNOFzvhCYF0wOvjbA1FgnEB/vdeN6OiZ1/oTxPmZXn5vC9p4xUsfhwNiRoJyaQQJo55DSJKtYAZo4zdN/W+I1ufYauVQDGxyA0q2MBrbpz2xLdB1Q46LUHWD3L+ezGr5DxmdNqYq7TGeZyeSYYSytd2ixStejGI5U8F/pSyFmY+DGciG4oMHrZmuMruAhTAmW+NYT6TiEQKvoHbLiJgVOjbRIc7jXQh/aJ7V9vGYHWsgpz2z4Xp8fbz805qxozF3PhhNqkxIZeiSWwM0K96dnjrkyys4o+8LoOJfbG1DAfU4LlIvXyi4Ph1skdjllnt22levWpB9xNGBj6SgxqeEXAFJNUd4ASTI98p/ptUyO4S1lzU3Y3wYtUUOZaA03yim+O0cqMWYWje8Qq4b8BZ5rg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 0eaa3d1a6cd1..aaa359a147b2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2261,6 +2261,7 @@ int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, static inline int munmap_sidetree(struct vm_area_struct *vma, struct ma_state *mas_detach) { + vma_start_write(vma); mas_set_range(mas_detach, vma->vm_start, vma->vm_end - 1); if (mas_store_gfp(mas_detach, vma, GFP_KERNEL)) return -ENOMEM; diff --git a/mm/nommu.c b/mm/nommu.c index 57ba243c6a37..2ab162d773e2 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -588,6 +588,7 @@ static int delete_vma_from_mm(struct vm_area_struct *vma) current->pid); return -ENOMEM; } + vma_start_write(vma); cleanup_vma_from_mm(vma); /* remove from the MM's tree and list */ @@ -1519,6 +1520,10 @@ void exit_mmap(struct mm_struct *mm) */ mmap_write_lock(mm); for_each_vma(vmi, vma) { + /* + * No need to lock VMA because this is the only mm user and no + * page fault handled can race with it. + */ cleanup_vma_from_mm(vma); delete_vma(mm, vma); cond_resched();
Write-locking VMAs before isolating them ensures that page fault handlers don't operate on isolated VMAs. Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- mm/mmap.c | 1 + mm/nommu.c | 5 +++++ 2 files changed, 6 insertions(+)