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 1C61FC6FD1A for ; Tue, 7 Mar 2023 16:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjCGQR2 (ORCPT ); Tue, 7 Mar 2023 11:17:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjCGQR0 (ORCPT ); Tue, 7 Mar 2023 11:17:26 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955038C512 for ; Tue, 7 Mar 2023 08:16:52 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id oj5so13711129pjb.5 for ; Tue, 07 Mar 2023 08:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1678205812; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=UYrq8v4HuBX2RB3d/VYQuTqaXQLxDy94/DGyKGTa8GE=; b=hhzoLo9mKt/chtZRRSOWW58mZp/EbLNymdzmTurgTLcgtj8rNx6VnB/zZIJiN5dEMU eVe5J6srcOE82KYyn5ItH6i9pMruynIPB389vTFujaSn/WVOs0lKDCeeyD+wkJS5kmr9 vRbRLHKU1Jo6wjY7Af+eOUM374qWjJrS6eTxxIL3WGPR9d7y47OHFyNzOdNF5ND96sdP XywFbkdI+e0GX6cdCgibnT1u4bIUjU256+5wLjw1VjSrShhAQAX69wZdErCstme3BwZe ZjJPbdMR3xt2o0B7+zoNSUs1nlpJj5QYPHkos75VEGPw3Hmk75Dm0DaoigmV72xRC4OF 5jkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678205812; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=UYrq8v4HuBX2RB3d/VYQuTqaXQLxDy94/DGyKGTa8GE=; b=RCD1REuXWr7W5Kef8qhrv4j7gaOuSQGEN0izi7x/UNhtn7phGtXUEWNIOc4NDhVYOa uScD8NKv5sHGVe/NegZo97lP65uX8YH4NtFAVW+iBOj1X6l0NIhSq3pHKguMFMR3A3fY 6ucqfmomkEzXniydFtpltMuNrvTse1Qzmae1ZkBVh55WJhNcY2SIe3AuyXt07fhDqA/C EJaCmMTO5bJQQCndtqr1+l74M8RHjrE6OXVEkzJyqiDiNaxWWKs3t4ngz1GC3awI6A1Y j8tMQEZrX1cJ20t+f/EmAvkANaBKAnzDhy8wys4xlBtuUAiZFJPa1xhM7Cw3tEn+MRjJ ksgg== X-Gm-Message-State: AO0yUKUodByyac6rzLk0s1ARZmUetqud1h65ZVaw7PvyyVEMlpcH6tMx u4XM47Zp8ebtNN2ygx3HLy+2dtINGhIzL4u81U4= X-Google-Smtp-Source: AK7set88BIwUJLFdpOXlbPGslKaEFH1+u9BuN0cxiLp2l426wfCtLQ01n+NArA7B7dU5e3lv3y6Fyw== X-Received: by 2002:a17:90b:3ec9:b0:230:7c78:6a7 with SMTP id rm9-20020a17090b3ec900b002307c7806a7mr15672363pjb.28.1678205812067; Tue, 07 Mar 2023 08:16:52 -0800 (PST) Received: from [10.200.8.102] ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id fv24-20020a17090b0e9800b002340f58e19bsm7568391pjb.45.2023.03.07.08.16.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Mar 2023 08:16:51 -0800 (PST) Message-ID: Date: Wed, 8 Mar 2023 00:16:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] maple_tree: Fix mas_skip_node() end slot detection To: Snild Dolkow , Peng Zhang , "Liam R. Howlett" Cc: Stable@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton References: <20230303021540.1056603-1-Liam.Howlett@oracle.com> <73971153-b46e-0332-aa4a-0dbe0a59fd22@sony.com> From: Peng Zhang In-Reply-To: <73971153-b46e-0332-aa4a-0dbe0a59fd22@sony.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Snild, 在 2023/3/7 22:30, Snild Dolkow 写道: > On 2023-03-07 14:05, Peng Zhang wrote: >> Hi, Liam, >>> -    } while (slot > slot_count); >>> +    } while (mas->offset >= mas_data_end(mas)); >>> -    mas->offset = ++slot; >>> +    mt = mte_node_type(mas->node); >>>       pivots = ma_pivots(mas_mn(mas), mt); >>> -    if (slot > 0) >>> -        mas->min = pivots[slot - 1] + 1; >>> - >>> -    if (slot <= slot_count) >>> -        mas->max = pivots[slot]; >>> +    mas->min = pivots[mas->offset] + 1; >>> +    mas->offset++; >>> +    if (mas->offset < mt_slots[mt]) >>> +        mas->max = pivots[mas->offset]; >> There is a bug here, the assignment of mas->min and mas->max is wrong. >> The assignment will make them represent the range of a child node, >> but it should represent the range of the current node. After >> mas_ascend() returns, mas-min and mas->max already represent the >> range of the current node, so we should delete these assignments of >> mas->min and mas->max. > > > Thanks for your suggestion, Peng. Applying it literally by removing > only the min/max assignments: > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index 6fc1ad42b409..9b6e581cf83f 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -5118,10 +5118,7 @@ static inline bool mas_skip_node > >         mt = mte_node_type(mas->node); >         pivots = ma_pivots(mas_mn(mas), mt); > -       mas->min = pivots[mas->offset] + 1; >         mas->offset++; > -       if (mas->offset < mt_slots[mt]) > -               mas->max = pivots[mas->offset]; > >         return true; >  } > > > This allowed my test to pass 100/100 runs. Still in qemu with the test > as init, so not really stressed in any way except that specific usecase. > > //Snild Thanks for the test, I'm happy if it happens to fix your problem. So a patch was made. This patch needs to be applied after Liam's patch. Sincerely yours, Peng.