Message ID | 20230425110511.11680-8-zhangpeng.00@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323850vqo; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) X-Google-Smtp-Source: AKy350bXxJtVHp4qDgZ7uLxDhR99lvBDSYkDr1aG/MTmMcYhRClwPaTQAQp9PZc+5eAZXr27PtN2 X-Received: by 2002:a05:6a20:72a4:b0:f2:c90a:9e0 with SMTP id o36-20020a056a2072a400b000f2c90a09e0mr14279151pzk.3.1682420913361; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420913; cv=none; d=google.com; s=arc-20160816; b=rJZHFdHMksi9pJXGP6TBtFDZz/bjZayo7NYEelfB1myiO9Et7UMrN3sKkwdDKAk9kS IzAZDvYYQc295IY0YKWczfZjbI3Jpn9/BmIWi/26Ek1ae3uIguTqnhn+QrHrigxmSRrR rrBkkVA42SK173uE3QDSixk9zaiiGVVlnCZX1DlLIDfSVfvP6Ado5HmdMj9qHyRhnkr2 +4rTLa1sscpGM432u/PoC5cJRfRLeSiFPKONgEg+uYUjj7bjFAt9Q6b8T/SrOfrLGXop WmiFpxS+ZhV7ea2MdWbapMylQorHbRs65+KqVNyIj+yYN60nSC1jxlUfS1cmZLE8bTT9 6hpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=Tyg8NsADcj8CPiN+qa+SmcSaYQDNDlVJ2ORo+gQhd/oZK7K+kX4pwbM8Mn74lciC+v /CR/4ni4cGvIqSV96Bk25OWMqvTO8j07m+mVfB4uHbbkUEDqicMR7uvafzqGZumSE1FT L85Of4zuslfxN+KyHrad8l5MqONFiOWzQMGQM8JaYECKUHwWIoU4zVulD7Qrm1M/RrZq Aw2cRGX5I31VFC1uOwN9wRZ+ytwOB0w9vVTlSiFoca4KA4fSaMhSjg25EIqegqQy6TT7 FNcaBk0+f95L+WpA0PL1l/+AvrKYqB8dOLsejqaB0IQWqTRz+1++1FtRNiJLxkb6m17K sIrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jipQmnHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a632108000000b0050faaed4f76si12785862pgh.751.2023.04.25.04.08.20; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jipQmnHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233963AbjDYLG3 (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Tue, 25 Apr 2023 07:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbjDYLGR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Apr 2023 07:06:17 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415D812CB5 for <linux-kernel@vger.kernel.org>; Tue, 25 Apr 2023 04:05:48 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-63b7b54642cso4131733b3a.0 for <linux-kernel@vger.kernel.org>; Tue, 25 Apr 2023 04:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420748; x=1685012748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=jipQmnHiGZqHhFj+pjse8A990ppkL1/uxO9HRdscpit7rhuWxH1VtL8WteZPa//UVl d+QYWMUc3Pd0xNIJ5KCnsF9R2zsXUbxhe79MilPyoF5EbgQWgrgD5Yx/Z643QyvsML8e Y/jlWVM3tUMLV/IXawWDmC1VAS3dP/bzZfDjJDUx7QS7NhTg5FRO+N5DpeKFva0YH+ux jJWMrmPke8pBOQm1JHvFPXk9am07Mtp+Z4X0pBvH9tYeY/Ky6BThaNUVjVEk3qJFoxRR s2JD+th6vAVyzSwwRovJ2WxkiFVq+PiDC67vi7LzP0ZtSLmtotp3zsqbzMeCtXArnENH cbUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420748; x=1685012748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=AKOyMqkEcgAWfpd5yja7UolAR7ZUTvwMTC/ix/83lgugveVukpQydg38PHfOf4UqO+ 7R1+zmPaHMoS736BEAaNbieixEI3EjJ9zpwmVVlB7ebo6ceN2mSocNKKb+sgwYwd9ICH h2nzaG+Uzo420/bmul4ngVhAS2vAL6s9pyoz+2MqPg4tkYX/I/f4AHLClA+rH7l9u4ph HueN2Jasot26bY7dW7SoWmfl+A8s6YXfG2+I2xmpbaXM9OuhMG+L2FyVh2Icr1jeik4W jmNyxICwlneZoBzWoaFA5fRtRd7WntG5aX4P94Mt+clbLeGSy0eAYgYyUn7Xl+QI0tKF y7Hg== X-Gm-Message-State: AAQBX9fBeRMZi4wfT+/Ft90HLpg4hh5BGxWvDKa0asSvKH8JOfGucWCQ D7ueEmvOiyhNNDVG+pj27D6F+w== X-Received: by 2002:a05:6a00:1887:b0:624:7c9a:c832 with SMTP id x7-20020a056a00188700b006247c9ac832mr22104593pfh.8.1682420747660; Tue, 25 Apr 2023 04:05:47 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:47 -0700 (PDT) From: Peng Zhang <zhangpeng.00@bytedance.com> To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang <zhangpeng.00@bytedance.com> Subject: [PATCH 7/9] maple_tree: Delete redundant code in mas_next_node() Date: Tue, 25 Apr 2023 19:05:09 +0800 Message-Id: <20230425110511.11680-8-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146191864526556?= X-GMAIL-MSGID: =?utf-8?q?1764146191864526556?= |
Series |
fix, rework and clean up for maple tree
|
|
Commit Message
Peng Zhang
April 25, 2023, 11:05 a.m. UTC
When offset == node_end is satisfied, go to the parent node, mas->max
will not change. So there is no need to update min on the move.
Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
---
lib/maple_tree.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Comments
* Peng Zhang <zhangpeng.00@bytedance.com> [230425 07:05]: The title of the patch seems wrong. This isn't redundant code and you aren't deleting it.. you are moving a block of code outside a loop. You did modify the check though, is that the redundant code? > When offset == node_end is satisfied, go to the parent node, mas->max > will not change. So there is no need to update min on the move. Please try not to state the code in your commit message. I have moved this block of code in patch 27/34 [1] > > Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> > --- > lib/maple_tree.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index 83441ef2e1f57..8bfa837b7b752 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -4616,7 +4616,8 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, > enum maple_type mt; > void __rcu **slots; > > - if (mas->max >= max) > + min = mas->max + 1; > + if (min > max) > goto no_entry; What happens on overflow? > > level = 0; > @@ -4624,10 +4625,6 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, > if (ma_is_root(node)) > goto no_entry; > > - min = mas->max + 1; > - if (min > max) > - goto no_entry; > - > if (unlikely(mas_ascend(mas))) > return 1; > > -- > 2.20.1 > [1] https://lore.kernel.org/linux-mm/20230425140955.3834476-28-Liam.Howlett@oracle.com/
在 2023/4/26 00:45, Liam R. Howlett 写道: > * Peng Zhang <zhangpeng.00@bytedance.com> [230425 07:05]: > > The title of the patch seems wrong. > > This isn't redundant code and you aren't deleting it.. you are moving a > block of code outside a loop. You did modify the check though, is that > the redundant code? > >> When offset == node_end is satisfied, go to the parent node, mas->max >> will not change. So there is no need to update min on the move. > Please try not to state the code in your commit message. > > I have moved this block of code in patch 27/34 [1] > >> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com> >> --- >> lib/maple_tree.c | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> index 83441ef2e1f57..8bfa837b7b752 100644 >> --- a/lib/maple_tree.c >> +++ b/lib/maple_tree.c >> @@ -4616,7 +4616,8 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, >> enum maple_type mt; >> void __rcu **slots; >> >> - if (mas->max >= max) >> + min = mas->max + 1; >> + if (min > max) >> goto no_entry; > What happens on overflow? Yes, I made a mistake. I will drop this patch since you have updated the code in patch 27/34. > >> >> level = 0; >> @@ -4624,10 +4625,6 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, >> if (ma_is_root(node)) >> goto no_entry; >> >> - min = mas->max + 1; >> - if (min > max) >> - goto no_entry; >> - >> if (unlikely(mas_ascend(mas))) >> return 1; >> >> -- >> 2.20.1 >> > [1] https://lore.kernel.org/linux-mm/20230425140955.3834476-28-Liam.Howlett@oracle.com/
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 83441ef2e1f57..8bfa837b7b752 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4616,7 +4616,8 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, enum maple_type mt; void __rcu **slots; - if (mas->max >= max) + min = mas->max + 1; + if (min > max) goto no_entry; level = 0; @@ -4624,10 +4625,6 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, if (ma_is_root(node)) goto no_entry; - min = mas->max + 1; - if (min > max) - goto no_entry; - if (unlikely(mas_ascend(mas))) return 1;