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 763EDC77B6F for ; Tue, 11 Apr 2023 13:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbjDKNrQ (ORCPT ); Tue, 11 Apr 2023 09:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjDKNrP (ORCPT ); Tue, 11 Apr 2023 09:47:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9EE4E48 for ; Tue, 11 Apr 2023 06:47:14 -0700 (PDT) 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 73DA9626A4 for ; Tue, 11 Apr 2023 13:47:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81506C433EF; Tue, 11 Apr 2023 13:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1681220833; bh=1KOfcPJrV7QzWaCNrczO2gv93Qce6ALZeIWQpMQtTVM=; h=Subject:To:Cc:From:Date:From; b=nycDm1Z/P4/PmAorMwgpild/E8v3va1voDaY1EO5FUOYEcbjBGG98cN6Advs0HuB6 8SOZ2a9EQbQ1MuX80W/8/EMn2h/C9rVDI0D/9ex8VJUs8w0U3ce65LVy40KrMcYDV1 wXJ4rAF5l7Q2ecz2h2gShdBNB0qNZ585cqewGbFY= Subject: FAILED: patch "[PATCH] maple_tree: detect dead nodes in mas_start()" failed to apply to 6.2-stable tree To: Liam.Howlett@oracle.com, akpm@linux-foundation.org, stable@vger.kernel.org, surenb@google.com Cc: From: Date: Tue, 11 Apr 2023 15:47:03 +0200 Message-ID: <2023041103-washcloth-overplay-32db@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 6.2-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.2.y git checkout FETCH_HEAD git cherry-pick -x a7b92d59c885018cb7bb88539892278e4fd64b29 # git commit -s git send-email --to '' --in-reply-to '2023041103-washcloth-overplay-32db@gregkh' --subject-prefix 'PATCH 6.2.y' HEAD^.. Possible dependencies: a7b92d59c885 ("maple_tree: detect dead nodes in mas_start()") 46b345848261 ("maple_tree: refine ma_state init from mas_start()") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a7b92d59c885018cb7bb88539892278e4fd64b29 Mon Sep 17 00:00:00 2001 From: Liam Howlett Date: Mon, 27 Feb 2023 09:36:01 -0800 Subject: [PATCH] maple_tree: detect dead nodes in mas_start() When initially starting a search, the root node may already be in the process of being replaced in RCU mode. Detect and restart the walk if this is the case. This is necessary for RCU mode of the maple tree. Link: https://lkml.kernel.org/r/20230227173632.3292573-3-surenb@google.com Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Liam Howlett Signed-off-by: Suren Baghdasaryan Cc: Signed-off-by: Andrew Morton diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 095b9cb1f4f1..3d53339656e1 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1360,12 +1360,16 @@ static inline struct maple_enode *mas_start(struct ma_state *mas) mas->max = ULONG_MAX; mas->depth = 0; +retry: root = mas_root(mas); /* Tree with nodes */ if (likely(xa_is_node(root))) { mas->depth = 1; mas->node = mte_safe_root(root); mas->offset = 0; + if (mte_dead_node(mas->node)) + goto retry; + return NULL; }