From patchwork Thu Feb 16 05:17:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13142499 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3CA1C61DA4 for ; Thu, 16 Feb 2023 05:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D48C6B0081; Thu, 16 Feb 2023 00:18:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 75EB66B0082; Thu, 16 Feb 2023 00:18:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64C7D6B0083; Thu, 16 Feb 2023 00:18:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 561F56B0081 for ; Thu, 16 Feb 2023 00:18:12 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3AAC6A0BD0 for ; Thu, 16 Feb 2023 05:18:12 +0000 (UTC) X-FDA: 80471998824.08.F4E0CDE Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf11.hostedemail.com (Postfix) with ESMTP id 73B7E4001A for ; Thu, 16 Feb 2023 05:18:10 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=WMbcZd2H; spf=pass (imf11.hostedemail.com: domain of 3kbztYwYKCOYacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3kbztYwYKCOYacZMVJOWWOTM.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=1676524690; 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=/TbDrnT4JTA4cMZmAjPRNE76LJNgcWEHHiVobOaA+Y8=; b=4WfA5llvjBujpe7NDyjF1kVmZnOBwDA/z2WZV1KViV/hW1LslylJQNx4A5iFQ6Y/fRnMDb CZF0/3Ya0S25l2juabcc2w0OLAGhvUA2le6i9aA/Lc+Fwm2KJBAi+BVNL3EFncjJ8afyUQ ODF9SI1EugGqshfk5WsxfXLvueG+ijc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=WMbcZd2H; spf=pass (imf11.hostedemail.com: domain of 3kbztYwYKCOYacZMVJOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3kbztYwYKCOYacZMVJOWWOTM.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=1676524690; a=rsa-sha256; cv=none; b=LXB7xtT2HFb3mdu9PG7Gvak+xkKuKRtFnXooCAgnBQ0hE5h0AYh+SoQNbZBu1p0ExUPM1f 0fKRXZs00d3B4KXEfEe7+vBi506jI68hVBGZeAampqKw83aPXlqKJq1Em5VoMGZiBRLTJg QzCv6238U54RIBfGSTfjD58u1sOub80= Received: by mail-yb1-f202.google.com with SMTP id p83-20020a25d856000000b0095d2ada3d26so831377ybg.5 for ; Wed, 15 Feb 2023 21:18:10 -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=/TbDrnT4JTA4cMZmAjPRNE76LJNgcWEHHiVobOaA+Y8=; b=WMbcZd2H6xEYgh8jPBjtr3c52H6Pfawu+33AP54ppxn4975bHziKOFepXARIS5jFg+ e6WwvlJoOPdxReXGpPCKc/NAAxfX4rbkO7DDbRqhMho2D2UtZ3EYOUrPrXvxo+yY0eM4 LMQxZ5khHMqm3h0sfllZRxbm/tuunDq1ItomZ38Vc5vIB77wslGrayg6KY3mbC66vptv Do13gHFViUDuIVWARk2CRzZ0n21J2khqCauKfFko2Yy6sWDAGtNFzpXO3m4fv/AYk9g9 lA127TPhorpqkZg7qKdsS4C88Qpbq0ryHT7Lx24g1uyKmp6VAfvqXa/maK1LoDRn6fAx 1DGw== 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=/TbDrnT4JTA4cMZmAjPRNE76LJNgcWEHHiVobOaA+Y8=; b=xrok2gtj/VJpzcEIe5GORJusOay5DMUeq0wMBN9Z8Bnppxs6bKHD1rRIDIe8AwYNSi wyuehuvP17mluZgB2tTXmrj61uV51Uo6Fk4NXw42UzbvS7geqTyMIauDgLP0EhUhbmih tRoipgYw28Y/T+0Z6kGP402TzWbBnqkBm8We9QBZxL4LKImOo0qsbjAgsf4kneiLXjP/ AHgIT8PE65eeDJY+ZfAbr0eUfBq8saKVa4dEtZQSzTHj/K5XEwtn2p7J8Hqtjd5OZ0Uc K+jT/rcA8Vg+HBB3Elbq0egHj7XlaAek7ipq4ExKeIV9ai4Z2fioObI3mbN+dFumSMb+ sVpQ== X-Gm-Message-State: AO0yUKWTyFDwkMLhpVN8CFqNFJp6ZOhVyOIQe/aH5CN0PUXeRJk+u3bW ib1C2W1LjlMdNvTuC7Uj1WSFdeKhXc0= X-Google-Smtp-Source: AK7set9oeDTHuLB1nfzndbZXzwVBlMHEMtdn96b6e8LnbJxiPKVQLZhG0+zpZpEt4JvzRmnu9oC+9ACRvag= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:f781:d5ed:1806:6ebb]) (user=surenb job=sendgmr) by 2002:a25:7805:0:b0:8d7:9497:cbb3 with SMTP id t5-20020a257805000000b008d79497cbb3mr12ybc.5.1676524689233; Wed, 15 Feb 2023 21:18:09 -0800 (PST) Date: Wed, 15 Feb 2023 21:17:21 -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-7-surenb@google.com> Subject: [PATCH v3 06/35] maple_tree: Add smp_rmb() to dead node detection From: Suren Baghdasaryan 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, "Liam R. Howlett" , Suren Baghdasaryan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zZeiCZJB3T+2jtVYe6A 3AyE2HEr Kk0VVuu/mpS9twQKgVeeBaJZ7mnuB0LtPYPKFRuXBCjzeBow0TTn/gZQoKTAYtil3FiHZHDSmGlU1FV9AgZDmACQF2JJ2ZhP+Sr6GJjSSEtpfL5BMwEJ3kHGpmSuWb5E3HzcVaMGzLUVXr0LuYkZ5uCP67QHmizj83f8PsDlP0W+/8R3CHt/6RPDfLFkPkoxf8OKR/B1iXL4koora1DGU9v/x9EItW0weONYwel74H6VecR1Yf9YURC4aAzwZZDKk6xemDtT85B9fHCv3uMj2RtNkEPQVlSK2cC38Nh4HAU/JWTTL9FL6XC5+QvPAUtmwjDiBDMrblSZwfhGQywZxlUMG5aYj7XXRuPQfJg6h1WEWAaWniYMbG4ZDGqmBqz5AU1ELzB5SWo9eforifIRcUIbd05D0hmdcCDFdPQHJQxf7mF7DWW35ury65/R+AipFFppyRqIWjsYeI+uHVuy5q4K9/i0IthHBlI1Yyp/SEDiiqL26ooLVw/U/Z16pNA4nPBIApSIhJQy8gq0oOKxKV0fhIA9lLYnv7Tst97/Kk0N9aCHvgbU4NJ68+CULgh+oX+aUXhlxrjevNokied/JQmvFt5FTK2i2+9xm 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: From: "Liam R. Howlett" 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. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan --- lib/maple_tree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6b6eddadd9d2..8ad2d1669fad 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -539,9 +539,11 @@ static inline struct maple_node *mte_parent(const struct maple_enode *enode) */ 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 struct maple_enode *enode) 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); }