Message ID | 20230227173632.3292573-11-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 B757AC64ED8 for <linux-mm@archiver.kernel.org>; Mon, 27 Feb 2023 17:37:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52D626B0087; Mon, 27 Feb 2023 12:37:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DDBF6B0088; Mon, 27 Feb 2023 12:37:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A6B16B008A; Mon, 27 Feb 2023 12:37:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A6A26B0087 for <linux-mm@kvack.org>; Mon, 27 Feb 2023 12:37:04 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B29451A0B02 for <linux-mm@kvack.org>; Mon, 27 Feb 2023 17:37:03 +0000 (UTC) X-FDA: 80513777526.20.F4A44FD Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf23.hostedemail.com (Postfix) with ESMTP id E6D77140004 for <linux-mm@kvack.org>; Mon, 27 Feb 2023 17:37:01 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="jX0E/sUV"; spf=pass (imf23.hostedemail.com: domain of 3Per8YwYKCCwacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Per8YwYKCCwacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@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=1677519421; 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=29YuznebDbhH7LJ7uqA8Selv98qAa02JmRVPnHaqVO4=; b=dHsuHQYPoPWhhke5nkxdq/i6ANxO6bpzi+k7ql1Fd8+fjPUiSmZFSmiH4Peh0cMlCPNmo9 lbo/bLU9rCDdevD0fxl2RWAscDWSfql8bsnUbgRMVG5b8snQLpOBQ6ma9IW/1ZWlVXC+Eq sEDA9t75O1xbHMknqks0i04Jav3bQdE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="jX0E/sUV"; spf=pass (imf23.hostedemail.com: domain of 3Per8YwYKCCwacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Per8YwYKCCwacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677519421; a=rsa-sha256; cv=none; b=VuELfeVvFmEz8cFbyWYHQUqnP4xG78QLj8R5dvC8J8rgAP5mv9ZoP7MLCiFqr0kX9vWZLX QjsQ358JYwmxSssIrwzu897RMyng+tNajECYHSMpyWXeJkanUXBKcajwwGZ2jXUdAhJqgS P8eZ9Cn+4PgE1fdJnpZyAE+xoO3901Q= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536bf649e70so153078417b3.0 for <linux-mm@kvack.org>; Mon, 27 Feb 2023 09:37:01 -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=29YuznebDbhH7LJ7uqA8Selv98qAa02JmRVPnHaqVO4=; b=jX0E/sUVT2RKYWg5Tqa21wWzSsitbAZllQiaBV4eWJXbUNmmhHROoBx1qNz1dBdUuE WfwseHSvUNs7qQdK+oiHVNrKDTVUoZgUvG4zzPJtFXGpgjghqMQHZP4+pvFGIZY9K8t8 yTb/HpAgn0jfVzcS4IzWrxVVhGHhJpK4EoMdSwUP/MFG5D0Q4nJDsYGVVLA1YMlIDxWr /VFBixWLHZCmRtwCrTiJJEDxVSpInKYA+7RDdnLaY6ZEJ31POIP0qLghcCdmVf5ptWUG sRbVaoL3AhiMndAmHz8lepZWlnznP3Urg+vUr3DV+pv2Gj3JIWJnnqJV/02ALHT1NaZc S6wg== 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=29YuznebDbhH7LJ7uqA8Selv98qAa02JmRVPnHaqVO4=; b=7Habno1kLU4pMALaTvq4/Fg45L4qTnEhBZ/Y9UPhkjqrl48I9O/EHwhIP2FCzZHF+A wkbOH5zu9+Yy9wV5Wo1B5mo3ZtyeuNp6cB9FwyihJW4EQlmDox2Qevslk3e/KBe7SCW9 XBtlbEVbgFdzkvdgUz1nsXgVsCO4+oQzL5eVoMErkEo7Dgn2q5nRqquC9Sd6W5Vn5hYN exFVMRoTkJl82Haontx3gwOXsAt0r9rVEdISF+FJR+fMn2wYwVrYukODxexJtqVQZJng q1ylbDis5nzDi07bh4Y0klIbUn/IkkgvjSlJr2gcOYWp1Ugp8lsYjfvoSk8wjhoLgT8H FU7A== X-Gm-Message-State: AO0yUKUPVqK4caL44pn9PSk4l9wLmpqr4VBeEoDM9tZqp6wOJ+Ik4Yc4 UPPVfg1C/4OXrpurGyUPKY5nR8UdEYs= X-Google-Smtp-Source: AK7set+1Pq3oRMVl5cZH8khR0Bvwd8LGMD5WFRsqtwPODZNGlHBw37TZClpeLubRs3LjGXy9DC4x47Xc4Uo= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:e1f6:21d1:eead:3897]) (user=surenb job=sendgmr) by 2002:a25:9390:0:b0:a53:5825:f25b with SMTP id a16-20020a259390000000b00a535825f25bmr6018468ybm.0.1677519421007; Mon, 27 Feb 2023 09:37:01 -0800 (PST) Date: Mon, 27 Feb 2023 09:36:09 -0800 In-Reply-To: <20230227173632.3292573-1-surenb@google.com> Mime-Version: 1.0 References: <20230227173632.3292573-1-surenb@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230227173632.3292573-11-surenb@google.com> Subject: [PATCH v4 10/33] mm: rcu safe VMA freeing 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E6D77140004 X-Stat-Signature: n4x1n17jpywqyth7gx5p9ji8ogdd3r43 X-Rspam-User: X-HE-Tag: 1677519421-548033 X-HE-Meta: U2FsdGVkX19qUyqDTTyIJEiD6YhZ2uh22Nz9UPsg/qjl5fNvsXEUY3nfx35m4kWJjUvWAe+DUgBIVpmG0wB8VT5JTf9KuViCNLJ3E+atyAgp8I/j3Jc2FRtEfkaV3bQoD1kFu896jnf3/35uttqYkZR4JZkt1e5MQGURVAG6O1P+MjKsG2KJAByMEXhMWy8PRoLF+dO/MU7VSY4rhQbJ1rfzDfbHQi5y8Hs3UNSG4UoRU2Vk8zNORMMgl0B4EBNxp4ZlTrUJ6qoGTHol7TiucVz2A8vRuCubvPKR6v4RdLnykWDOkKWsVnOaYgtK8sqD3n7Wxd0xJctgU68gwzBX9cI5wcB7XyTroPsVcyFHm1KnL79FfoHXJMmTaifaL2bzYf11UP1bd/44Bd1tBHdvRyb8LhXFoB6QQ4PP3Xu2iU53yXy118AuO0ZhuCULZaYLNUElqHQa/tkyC/6TmTh6I+mSDRJl4kNLicXZShYmxlXLCNzFHyN7eAovDSleIA3tw+WoiV5Q1kbJdyS4Fsp/WCk8JznfQZUGjkUmtE17Lf7UMD53qzKUbNISgoHpjxl6Asyh7nH/p9BYTB95f65GGl3bvg+fYbv9r/9Hf/OpHaf/r0ScqwsG2tzu1wwi/0cYABbgrNNG6pidHpjo4puXCMWEYgim9XI/JA8bNtlIIpmg4Z8k05ePDXhwkqaaM33YwctG7TI0GM0JQFz1nSXM+FY5Q0PEg9Z1H3HWWISh0TphZRJ6rVzEVnQOw/XvgM331KSkaqz7RE5MDLnaYXPxzSWoYEibGdnbnCth+kpIPLaggBb2giIeYWB5cFR1kFrK9HuIhHw7K/3lQFM51BfMrzYqqVQiIJVdQZBNXf7C4kWDImGC6jpjNmekCl9ZdDxPP+DYyM+Fer0uC6+4FGC1Qfjso9SNYx0Hr4zqtXN9PyVaA8HnfgXL1JDaDMyYLt94EOdq/MNpQNfp8z/p0IO klIjTlDD Oqy3UJ9qztgJWoaEpPbxOX5ywji/YQNYZ8DvSlcnGZeeN7eM6FDw6RCaybUj5VbruK6ZsZdW0A07vULQdm/GfxNkJSyw/QffWLdXwCIvLEscVy7zIS5dv7AcKpD1x32cLS3lmjLJgC3by0jB3781K/ixJ0hFBpZXnL43hDEnbPFluSdXCQjgUkp9ST5jsk1yvqZtATkooT2NQGXNMBLBn3Gb3v9XHIT0tITbHfbJsTj1rWbfE1mUN84uiwhc9/jQ87+j85P+NmSjlw6CXrfVZqNUSQhNiRb+hZKDXo7nnYZbo+0ctmH7KPNN71WzVK0imKjFqJtmNHiShWjWtKGeYle58vFUP+PBSQlTc0uvlZ4JC44hggFCUIn4blndgcSqNmC5GxLHQBrMhFWOntwgPLwr4BtSgS8b9+5n3yLkKhv1ZPdWffDT1wJNYmIvhOh2sQ2CVO4kGACKhNDwYjMhzf7j30Y1vJHAs0UgxcXijna3X0+OHqAVMrXj7reBNrVjqnaTU35D343KGMLHvoVRxAeLzhkBIGMcnZEVJ9O9jwc8Id7iqiLNnSXWSVor+nphkglcxqHD4Y2hrvzpu86JT2Lb6fZ21kpW3os3UhjAMJv/xP970rU7HkRWArpViXOUGAxX718CYgaMmmcbgKv6cfh6LXZf/JD0JzJa3HAg2KJNBBR8LnItp2VjyUA== 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
|
expand
|
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 22b2ac82bffd..64a6b3f6b74f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -480,9 +480,16 @@ struct anon_vma_name { struct vm_area_struct { /* The first cache line has the info for VMA tree walking. */ - unsigned long vm_start; /* Our start address within vm_mm. */ - unsigned long vm_end; /* The first byte after our end address - within vm_mm. */ + union { + struct { + /* VMA covers [vm_start; vm_end) addresses within mm */ + unsigned long vm_start; + unsigned long vm_end; + }; +#ifdef CONFIG_PER_VMA_LOCK + struct rcu_head vm_rcu; /* Used for deferred freeing. */ +#endif + }; struct mm_struct *vm_mm; /* The address space we belong to. */ diff --git a/kernel/fork.c b/kernel/fork.c index abfcf95734c7..a63b739aeca9 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -479,12 +479,30 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) return new; } -void vm_area_free(struct vm_area_struct *vma) +static void __vm_area_free(struct vm_area_struct *vma) { free_anon_vma_name(vma); kmem_cache_free(vm_area_cachep, vma); } +#ifdef CONFIG_PER_VMA_LOCK +static void vm_area_free_rcu_cb(struct rcu_head *head) +{ + struct vm_area_struct *vma = container_of(head, struct vm_area_struct, + vm_rcu); + __vm_area_free(vma); +} +#endif + +void vm_area_free(struct vm_area_struct *vma) +{ +#ifdef CONFIG_PER_VMA_LOCK + call_rcu(&vma->vm_rcu, vm_area_free_rcu_cb); +#else + __vm_area_free(vma); +#endif +} + static void account_kernel_stack(struct task_struct *tsk, int account) { if (IS_ENABLED(CONFIG_VMAP_STACK)) {