From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33323C64ED6 for ; Mon, 27 Feb 2023 22:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbjB0WGa (ORCPT ); Mon, 27 Feb 2023 17:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbjB0WGO (ORCPT ); Mon, 27 Feb 2023 17:06:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7A8298CF for ; Mon, 27 Feb 2023 14:06:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2040260F43 for ; Mon, 27 Feb 2023 22:06:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74F25C433D2; Mon, 27 Feb 2023 22:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1677535568; bh=puv8Nal3ds9v+lwcVnAvJo+/9GYqqYOgXEnGzry3HIk=; h=Date:To:From:Subject:From; b=d5Zth+GQNOiZKzFKEAu7CeNqILROD+BPaw8mzbAwkRrfjFeIx0Hd90N2OXr1RQkPN qkuVSq68VtX+Z+ebwu8tWErqQi2QLeFDj0c1f6IGteBos9UOta9dgqiMa7IYffyKST Xa5jML5nLGtoz6tSqFUvkPcTIlNeaYzI9Af5cAEA= Date: Mon, 27 Feb 2023 14:06:07 -0800 To: mm-commits@vger.kernel.org, surenb@google.com, Liam.Howlett@oracle.com, akpm@linux-foundation.org From: Andrew Morton Subject: + mm-enable-maple-tree-rcu-mode-by-default.patch added to mm-unstable branch Message-Id: <20230227220608.74F25C433D2@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm: enable maple tree RCU mode by default. has been added to the -mm mm-unstable branch. Its filename is mm-enable-maple-tree-rcu-mode-by-default.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-enable-maple-tree-rcu-mode-by-default.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Liam R. Howlett" Subject: mm: enable maple tree RCU mode by default. Date: Mon, 27 Feb 2023 09:36:07 -0800 Use the maple tree in RCU mode for VMA tracking. This is necessary for the use of per-VMA locking. RCU mode is enabled by default but disabled when exiting an mm and for the new tree during a fork. Also enable RCU for the tree used in munmap operations to ensure the nodes remain valid for readers. Link: https://lkml.kernel.org/r/20230227173632.3292573-9-surenb@google.com Signed-off-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan Signed-off-by: Andrew Morton --- --- a/include/linux/mm_types.h~mm-enable-maple-tree-rcu-mode-by-default +++ a/include/linux/mm_types.h @@ -779,7 +779,8 @@ struct mm_struct { unsigned long cpu_bitmap[]; }; -#define MM_MT_FLAGS (MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN) +#define MM_MT_FLAGS (MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN | \ + MT_FLAGS_USE_RCU) extern struct mm_struct init_mm; /* Pointer magic because the dynamic array size confuses some compilers. */ --- a/kernel/fork.c~mm-enable-maple-tree-rcu-mode-by-default +++ a/kernel/fork.c @@ -617,6 +617,7 @@ static __latent_entropy int dup_mmap(str if (retval) goto out; + mt_clear_in_rcu(vmi.mas.tree); for_each_vma(old_vmi, mpnt) { struct file *file; @@ -700,6 +701,8 @@ static __latent_entropy int dup_mmap(str retval = arch_dup_mmap(oldmm, mm); loop_out: vma_iter_free(&vmi); + if (!retval) + mt_set_in_rcu(vmi.mas.tree); out: mmap_write_unlock(mm); flush_tlb_mm(oldmm); --- a/mm/mmap.c~mm-enable-maple-tree-rcu-mode-by-default +++ a/mm/mmap.c @@ -2277,7 +2277,8 @@ do_vmi_align_munmap(struct vma_iterator int count = 0; int error = -ENOMEM; MA_STATE(mas_detach, &mt_detach, 0, 0); - mt_init_flags(&mt_detach, MT_FLAGS_LOCK_EXTERN); + mt_init_flags(&mt_detach, vmi->mas.tree->ma_flags & + (MT_FLAGS_LOCK_MASK | MT_FLAGS_USE_RCU)); mt_set_external_lock(&mt_detach, &mm->mmap_lock); /* @@ -3042,6 +3043,7 @@ void exit_mmap(struct mm_struct *mm) */ set_bit(MMF_OOM_SKIP, &mm->flags); mmap_write_lock(mm); + mt_clear_in_rcu(&mm->mm_mt); free_pgtables(&tlb, &mm->mm_mt, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING); tlb_finish_mmu(&tlb); _ Patches currently in -mm which might be from Liam.Howlett@oracle.com are mm-mprotect-fix-successful-vma_merge-of-next-in-do_mprotect_pkey.patch maple_tree-be-more-cautious-about-dead-nodes.patch maple_tree-detect-dead-nodes-in-mas_start.patch maple_tree-fix-freeing-of-nodes-in-rcu-mode.patch maple_tree-remove-extra-smp_wmb-from-mas_dead_leaves.patch maple_tree-fix-write-memory-barrier-of-nodes-once-dead-for-rcu-mode.patch maple_tree-add-smp_rmb-to-dead-node-detection.patch maple_tree-add-rcu-lock-checking-to-rcu-callback-functions.patch mm-enable-maple-tree-rcu-mode-by-default.patch