Message ID | 20221113005618.29679-1-richard.weiyang@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1492563wru; Sat, 12 Nov 2022 17:09:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6X0xPBJIxnJVxo9A3FFGJ1s/sVpeTZ++8ljkd8rqR3Nd4Pnswal6NQFb+nqhbN7xioWMop X-Received: by 2002:aa7:c384:0:b0:461:5f19:61da with SMTP id k4-20020aa7c384000000b004615f1961damr6891936edq.34.1668301781764; Sat, 12 Nov 2022 17:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668301781; cv=none; d=google.com; s=arc-20160816; b=V/Zj/aLo43hQ/DJjjbgc6XDkmKWnXrZs4xxMa12zrWQgAtIdQ3EuiGOa1cEOzAB/lz wyxOsfdSsrM2kzAORtIdWRWfzzgs5gKdWtBGYkNChn+/9/zxKyF4zAVLGp/zX1iy5iaA QJat/D8aNYa9qfoJThzP8bXnXSrK0tMrHnnjmyYYkO8pqasswoRMYIYCBpsyidk9bxrR NoPJjmRr9bUq6WTEBRyFCTdrlLCqAlTeQo2hE4d23+lxMHEapplhYQBo5GUEBaX0b5Vn RnSltq2o/kef4QcVaCj4gmMzItq7Ne28XpiDP+xXZhQn1O9K6yw2oBULM1IZfCVemYAS 7eeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=W0SikHTdUbXQLGro61wDie+oPkKhps+RKTwvHMmIsLg=; b=WdcsSzpcpy7k/GgJHMNvnqxGw4/5aWRkJhrzaNbapplwSz1dDPuGzDvhkz9K4sXcmq L2S5tVCZ/fPa5/CaY1kFudE2D3Wslc9VvvQsqARwfEi67DEGeRQxBxDyvY9m5EiZffUe ADvuX1jicS58TF7Xs5TDXahttup/rT6LK232394c2jP7stiw3BjX+4H09qAahqNsV9Jw qTBmiNndVDUNW0gmp59xGwq74fsOI9J38swDIaXBWBkKLBp/3oocFvVzfO4u4cePh9jc NvVVNBYBhcOOJzD5UTEKZSJeT/bUXHxmTE7tyPhD3sTK0kZTvXtdLBj/gHtPzg4iwa3b J+qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mw93TmEe; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a0564021e9200b00458985e9d19si7288753edf.632.2022.11.12.17.09.02; Sat, 12 Nov 2022 17:09:41 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=mw93TmEe; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235040AbiKMA4r (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Sat, 12 Nov 2022 19:56:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiKMA4p (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 12 Nov 2022 19:56:45 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D457813D6E for <linux-kernel@vger.kernel.org>; Sat, 12 Nov 2022 16:56:44 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id a13so12589715edj.0 for <linux-kernel@vger.kernel.org>; Sat, 12 Nov 2022 16:56:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W0SikHTdUbXQLGro61wDie+oPkKhps+RKTwvHMmIsLg=; b=mw93TmEeH1gUrFjBnB2pV2QBDf+ZR6rzwh3OIkxUlRatK4s7HhNKVu7jXkoEG09aTI P0f8HQJhWzi4/70jiM86jX48e4C0NlM+4mMwlHpBlY0CCHhwjWCfghuNrhdqnS0bb71Z aBn1hfjfVeIPNv8JtPUW28yCoaIFakVMmzyOD97hJ25M5B15btMtjPK5ArTH+EjbCKTI CYxaNhakK1gZCX0CkGti6gNXeM8B+rkzZNOCw2vhMW1F/37bUPkyR2IrlXaxLcxTXZrO Y94Acve50lqRZ3eBoKOkVHEQjrTeyaqk/uZLWoOvkMZjudhlccgnHQR+7zQK25PjLoW8 5CIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W0SikHTdUbXQLGro61wDie+oPkKhps+RKTwvHMmIsLg=; b=xctt+fIuc4B1YlVd7L2CdNhZg0i3JdfIoQacFUjTN+C973IkjuSwibJEkcFrUFrQAF LGOzemOcx81rhP1mU/q75s/rnM9CnACEKynLHWSXJkqDJlpT9xfJypAO2A1k6c35V1jY G6mVYFfrZClXFmw8gRiSxGlZX7DU9PCQZ4V6wbllN+ldNOQnDx+U7QVTkpORzd7XNNUo 1Oc0MeyHS57KKYEd+P5BD+W4obJOzfXS7kEm7QbmKBc5wAYSUuho9Hzx2Z1mDLWTNj3q MABxDNYy9hqai6yNjmRCF6Yzv/qAE/5lMKgKKlzVb02AWxjwJJHlHmGbfIkjKpd9zll+ 8gxg== X-Gm-Message-State: ANoB5pmWPMHPrRim4NcEKJ2nPgNQW9QIjUkahS/s2wXTD1+8UqVakusF Dhl7bEO1etF5WQWEHiZobT8= X-Received: by 2002:a50:9eaa:0:b0:461:86b7:7627 with SMTP id a39-20020a509eaa000000b0046186b77627mr6974061edf.180.1668301003339; Sat, 12 Nov 2022 16:56:43 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id p25-20020a17090653d900b00779a605c777sm2398728ejo.192.2022.11.12.16.56.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 12 Nov 2022 16:56:42 -0800 (PST) From: Wei Yang <richard.weiyang@gmail.com> To: Liam.Howlett@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang <richard.weiyang@gmail.com>, "Liam R . Howlett" <Liam.Howlett@Oracle.com> Subject: [PATCH] maple_tree: not necessary to filter MAPLE_PARENT_ROOT since it is not a root Date: Sun, 13 Nov 2022 00:56:18 +0000 Message-Id: <20221113005618.29679-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1749341209368550991?= X-GMAIL-MSGID: =?utf-8?q?1749341209368550991?= |
Series |
maple_tree: not necessary to filter MAPLE_PARENT_ROOT since it is not a root
|
|
Commit Message
Wei Yang
Nov. 13, 2022, 12:56 a.m. UTC
Root node is return at the beginning, so we are sure bit 0 is not set.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
lib/maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
* Wei Yang <richard.weiyang@gmail.com> [221112 19:56]: > Root node is return at the beginning, so we are sure bit 0 is not set. > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > CC: Liam R. Howlett <Liam.Howlett@Oracle.com> > --- > lib/maple_tree.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index 9aad98c24f3e..f8c4755e7c75 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -436,7 +436,7 @@ enum maple_type mte_parent_enum(struct maple_enode *p_enode, > return 0; /* Validated in the caller. */ > > p_type &= MAPLE_NODE_MASK; > - p_type = p_type & ~(MAPLE_PARENT_ROOT | mte_parent_slot_mask(p_type)); > + p_type = p_type & ~mte_parent_slot_mask(p_type); I think there is a larger cleanup that can be done here. It looks like mte_parent_enum() is called from one location and that location is a wrapper. The check for the root bit should also probably trigger a WARN_ON() and still return 0. I don't think the callers are doing enough to validate it - although they should never reach this function with a root node. And, in fact, I am not doing enough in the test code since I didn't guard this correctly in the verification of the parent slot before calling this function. Thanks for pointing this out. I will send out a patch to clean this up shortly. > > switch (p_type) { > case MAPLE_PARENT_RANGE64: /* or MAPLE_PARENT_ARANGE64 */ > -- > 2.33.1 >
* Liam R. Howlett <Liam.Howlett@Oracle.com> [221115 09:29]: > * Wei Yang <richard.weiyang@gmail.com> [221112 19:56]: > > Root node is return at the beginning, so we are sure bit 0 is not set. > > > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > > CC: Liam R. Howlett <Liam.Howlett@Oracle.com> > > --- > > lib/maple_tree.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > > index 9aad98c24f3e..f8c4755e7c75 100644 > > --- a/lib/maple_tree.c > > +++ b/lib/maple_tree.c > > @@ -436,7 +436,7 @@ enum maple_type mte_parent_enum(struct maple_enode *p_enode, > > return 0; /* Validated in the caller. */ > > > > p_type &= MAPLE_NODE_MASK; > > - p_type = p_type & ~(MAPLE_PARENT_ROOT | mte_parent_slot_mask(p_type)); > > + p_type = p_type & ~mte_parent_slot_mask(p_type); > > I think there is a larger cleanup that can be done here. It looks like > mte_parent_enum() is called from one location and that location is a > wrapper. > > The check for the root bit should also probably trigger a WARN_ON() and > still return 0. I don't think the callers are doing enough to validate > it - although they should never reach this function with a root node. > And, in fact, I am not doing enough in the test code since I didn't > guard this correctly in the verification of the parent slot before > calling this function. > > Thanks for pointing this out. I will send out a patch to clean this up > shortly. On second thought, I will hold off for the 6.2 merge window for this to go upstream. Thanks, Liam
On Tue, Nov 15, 2022 at 02:31:15PM +0000, Liam Howlett wrote: >* Wei Yang <richard.weiyang@gmail.com> [221112 19:56]: >> Root node is return at the beginning, so we are sure bit 0 is not set. >> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> >> CC: Liam R. Howlett <Liam.Howlett@Oracle.com> >> --- >> lib/maple_tree.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> index 9aad98c24f3e..f8c4755e7c75 100644 >> --- a/lib/maple_tree.c >> +++ b/lib/maple_tree.c >> @@ -436,7 +436,7 @@ enum maple_type mte_parent_enum(struct maple_enode *p_enode, >> return 0; /* Validated in the caller. */ >> >> p_type &= MAPLE_NODE_MASK; >> - p_type = p_type & ~(MAPLE_PARENT_ROOT | mte_parent_slot_mask(p_type)); >> + p_type = p_type & ~mte_parent_slot_mask(p_type); > >I think there is a larger cleanup that can be done here. It looks like >mte_parent_enum() is called from one location and that location is a >wrapper. > >The check for the root bit should also probably trigger a WARN_ON() and >still return 0. I don't think the callers are doing enough to validate >it - although they should never reach this function with a root node. >And, in fact, I am not doing enough in the test code since I didn't >guard this correctly in the verification of the parent slot before >calling this function. > >Thanks for pointing this out. I will send out a patch to clean this up >shortly. > Yep, look forward your cleanup. While I have a question here. We get 4 types in maple_type, here we just return two of them. This means the other two is not possible to be parent node, right? >> >> switch (p_type) { >> case MAPLE_PARENT_RANGE64: /* or MAPLE_PARENT_ARANGE64 */ >> -- >> 2.33.1 >>
diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 9aad98c24f3e..f8c4755e7c75 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -436,7 +436,7 @@ enum maple_type mte_parent_enum(struct maple_enode *p_enode, return 0; /* Validated in the caller. */ p_type &= MAPLE_NODE_MASK; - p_type = p_type & ~(MAPLE_PARENT_ROOT | mte_parent_slot_mask(p_type)); + p_type = p_type & ~mte_parent_slot_mask(p_type); switch (p_type) { case MAPLE_PARENT_RANGE64: /* or MAPLE_PARENT_ARANGE64 */