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 A210EC64ED6 for ; Mon, 27 Feb 2023 22:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbjB0WGO (ORCPT ); Mon, 27 Feb 2023 17:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbjB0WGK (ORCPT ); Mon, 27 Feb 2023 17:06:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C531A298C8 for ; Mon, 27 Feb 2023 14:06:05 -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 5B7E060F46 for ; Mon, 27 Feb 2023 22:06:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEBF9C433D2; Mon, 27 Feb 2023 22:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1677535564; bh=gMACOlN4IVgGKd/jQDM70FPJagDV7x9A6THPwwkS7jI=; h=Date:To:From:Subject:From; b=Wmb/k2w58NU6V7Onk1ZWLwZT9KeyEhaLuBKZ8efWp2ZQtE3YYqCPEdDmc+v7B93pp yb/PODmkfrqIeZXmc33pfiy55bEhxy3+tZB2ighJMiUSslod/PS/wGwRHKA5VYWost YDqUmH+aS5N284Oyk4Jgn6hyci7wTmjSUubjxWxg= Date: Mon, 27 Feb 2023 14:06:04 -0800 To: mm-commits@vger.kernel.org, surenb@google.com, Liam.Howlett@oracle.com, akpm@linux-foundation.org From: Andrew Morton Subject: + maple_tree-add-smp_rmb-to-dead-node-detection.patch added to mm-unstable branch Message-Id: <20230227220604.AEBF9C433D2@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: maple_tree: add smp_rmb() to dead node detection has been added to the -mm mm-unstable branch. Its filename is maple_tree-add-smp_rmb-to-dead-node-detection.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/maple_tree-add-smp_rmb-to-dead-node-detection.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: maple_tree: add smp_rmb() to dead node detection Date: Mon, 27 Feb 2023 09:36:05 -0800 Add an smp_rmb() before reading the parent pointer to ensure that anything read from the node prior to the parent pointer hasn't been reordered ahead of this check. The is necessary for RCU mode. Link: https://lkml.kernel.org/r/20230227173632.3292573-7-surenb@google.com Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan Signed-off-by: Andrew Morton --- --- a/lib/maple_tree.c~maple_tree-add-smp_rmb-to-dead-node-detection +++ a/lib/maple_tree.c @@ -539,9 +539,11 @@ static inline struct maple_node *mte_par */ static inline bool ma_dead_node(const struct maple_node *node) { - struct maple_node *parent = (void *)((unsigned long) - node->parent & ~MAPLE_NODE_MASK); + struct maple_node *parent; + /* Do not reorder reads from the node prior to the parent check */ + smp_rmb(); + parent = (void *)((unsigned long) node->parent & ~MAPLE_NODE_MASK); return (parent == node); } @@ -556,6 +558,8 @@ static inline bool mte_dead_node(const s struct maple_node *parent, *node; node = mte_to_node(enode); + /* Do not reorder reads from the node prior to the parent check */ + smp_rmb(); parent = mte_parent(enode); return (parent == node); } _ 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