Message ID | 20220829212531.3184856-12-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 1D61CC0502C for <linux-mm@archiver.kernel.org>; Mon, 29 Aug 2022 21:25:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6E2B94000F; Mon, 29 Aug 2022 17:25:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF665940008; Mon, 29 Aug 2022 17:25:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9980694000F; Mon, 29 Aug 2022 17:25:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7D48D940008 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 17:25:58 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 535BE1602EB for <linux-mm@kvack.org>; Mon, 29 Aug 2022 21:25:58 +0000 (UTC) X-FDA: 79853912796.16.5FD35B0 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf31.hostedemail.com (Postfix) with ESMTP id 0C07D20047 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 21:25:57 +0000 (UTC) Received: by mail-pf1-f202.google.com with SMTP id o17-20020a056a0015d100b00536fc93b990so3576121pfu.14 for <linux-mm@kvack.org>; Mon, 29 Aug 2022 14:25:57 -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=iuFA+HN3YQAhGF4lKe/pszwBtaIFpTgsToRqXaNjG7k=; b=OQFmY5p6Pe2rtWh8HoOtibHP8P5GG7l2q0OSc7HNXnd2wSmQX9hqgXeo/WRhgSbde1 3GOMVRznNWUQpWpM6oRymYxlQgfSmhokZzxHMaOud6hAHMI7hRSvRQgnpTP2D9VCRijV tvYOdRbm6MoDu4UgOmxt7sejA6CQywedGjOTRBl30ijbrDgQETYn5oZOqnGCtaAYcPZu MjsJRXAG04ApiH5Z6mU8Nc2C+hXCaIEB6zH7hUa5Up7nSwAgqcd3I/44d6H2f140ISuN zqINoaSTwBSBF/Nj+3hF7XpzbCbRiSR9QvteChaGaDG9beNmWGZas127F5+VFT8rM/v5 R54A== 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=iuFA+HN3YQAhGF4lKe/pszwBtaIFpTgsToRqXaNjG7k=; b=mYMPlBZ2//GskHxIR72o/QsoxVHN4bcP2oAVLIEJx+7M6Tl3xbYJG85Ndhomt7L64Z 7yxUNQS0QQ9pAfhWHzGsGnXxLs+5S9CCQG/h324pjDEb4G1EeGA7Q2UffMQpgI7rBpWh y5aLaqBzXDGepP+Ai4K+jeBdUE6/97LPHrAl+suYndMj2A9CO/kderTHoT18iBUnaWxr CBvaBkO8Y66mhUK7p3J/d9uX97v4pvN1q+i27fzRh+Q3SNDgvefbR1YKeYk0tn6tCNpM gA6jpwhP63VgSsJJC64n4AnFws/qvSZoos2mjZ3qnuxZrAL7Dwi7dmOvh2aedDiqACmL EJoA== X-Gm-Message-State: ACgBeo2OBpKhyVTOKiMFazFW1nlPD635tAhhz/64eM4SzO56ZGZPqZay lRX0q0edFvo3oEl2QiiJ0v0QQIETIqQ= X-Google-Smtp-Source: AA6agR67llFT6eQ0+3Cyyc4Z2yCAV5KwAp4HusV+mlw9qyUeJ6m9H2aBfcEzix7gu6JpzsX42cg/TQ27QPw= X-Received: from surenb-spec.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e30]) (user=surenb job=sendgmr) by 2002:a17:90a:e558:b0:1fb:c4b7:1a24 with SMTP id ei24-20020a17090ae55800b001fbc4b71a24mr21023pjb.1.1661808355887; Mon, 29 Aug 2022 14:25:55 -0700 (PDT) Date: Mon, 29 Aug 2022 21:25:14 +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-12-surenb@google.com> Subject: [RFC PATCH 11/28] mm/mmap: mark VMAs as locked before merging or splitting them 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, 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661808358; a=rsa-sha256; cv=none; b=CrKgnAIfoopB3KqCahsY00Uy/iQfBJhevB7dU7lk0N4notR9pdk0UtknjTVuablqn/p5Ll 0WxUPJulaVF2RcVvBXyo5WFi4+/6LdqGrHn3v1ZYs99ECDWA3kAnd4bxiTVwlsp8/aEjTD i0f1j1g6Gk+V5NXq33SgxYkV/GDmhvg= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=OQFmY5p6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf31.hostedemail.com: domain of 34y4NYwYKCJQGIF2Bz4CC492.0CA96BIL-AA8Jy08.CF4@flex--surenb.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=34y4NYwYKCJQGIF2Bz4CC492.0CA96BIL-AA8Jy08.CF4@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661808358; 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=iuFA+HN3YQAhGF4lKe/pszwBtaIFpTgsToRqXaNjG7k=; b=APBvCaQHdRcQ+6+i21/Iip71geaM5Cq2Ga0BzOUnvt+K7jJxS5SVM5/0yIuJPl4t58SiY8 +Hymz3XNZVB6hCXyuH/w17MTMl5pwlWC6Z/l+kcTKF80a+lUXSNx5qmnccLuZqfWSDyfN4 eAZSfI9dommpCIEIa4ibkJRn8R7ucDY= X-Rspam-User: X-Rspamd-Queue-Id: 0C07D20047 X-Rspamd-Server: rspam12 X-Stat-Signature: gozryitnyxah88r6cfgx9dc9y1zs6ak9 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=OQFmY5p6; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf31.hostedemail.com: domain of 34y4NYwYKCJQGIF2Bz4CC492.0CA96BIL-AA8Jy08.CF4@flex--surenb.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=34y4NYwYKCJQGIF2Bz4CC492.0CA96BIL-AA8Jy08.CF4@flex--surenb.bounces.google.com X-HE-Tag: 1661808357-248361 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 proposal
|
expand
|
diff --git a/mm/mmap.c b/mm/mmap.c index ed58cf0689b2..ade3909c89b4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1147,10 +1147,17 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm, if (vm_flags & VM_SPECIAL) return NULL; + if (prev) + vma_mark_locked(prev); next = vma_next(mm, prev); area = next; - if (area && area->vm_end == end) /* cases 6, 7, 8 */ + if (area) + vma_mark_locked(area); + if (area && area->vm_end == end) { /* cases 6, 7, 8 */ next = next->vm_next; + if (next) + vma_mark_locked(next); + } /* verify some invariant that must be enforced by the caller */ VM_WARN_ON(prev && addr <= prev->vm_start); @@ -2687,6 +2694,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *new; int err; + vma_mark_locked(vma); if (vma->vm_ops && vma->vm_ops->may_split) { err = vma->vm_ops->may_split(vma, addr); if (err)
Decisions about whether VMAs can be merged or split must be made while VMAs are protected from the changes which can affect that decision. For example, merge_vma uses vma->anon_vma in its decision whether the VMA can be merged. Meanwhile, page fault handler changes vma->anon_vma during COW operation. Mark all VMAs which might be affected by a merge or split operation as locked before making decision how such operations should be performed. Signed-off-by: Suren Baghdasaryan <surenb@google.com> --- mm/mmap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)