linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, maple-tree@lists.infradead.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] maple_tree: use xa_is_internal() for better reading
Date: Fri, 9 Aug 2024 01:58:52 +0000	[thread overview]
Message-ID: <20240809015852.r3ksdkgivhht3ey3@master> (raw)
In-Reply-To: <2owp7odt4ryc42fzbtbxw6fg7zrkfi5g7tptyy4hgjpzqsthy2@46gbf75ibmz6>

On Thu, Aug 08, 2024 at 12:53:55PM -0400, Liam R. Howlett wrote:
>* Wei Yang <richard.weiyang@gmail.com> [240808 00:38]:
>> If entry is a special case, we need to expand root to store it. This
>> case is exactly the case of xa_is_internal().
>> 
>> Let's use xa_is_internal() for the check, which is friendly for
>> audience.
>
>Nack
>
>This check is to see if it will be detected as an internal node - this
>much is correct.
>
>But changing the check to use this function reads far worse than what
>exists today.  If you look at the code below, it seems to indicate that
>the internal entry is being inserted into the tree - but it's not an
>internal entry, it's an entry that would be detected as an internal
>entry.
>

From my understanding, you want to say xa_is_internal() only applies on "an
entry" in the tree instead of a "value" we want to insert into the tree.

But it looks current code already use xa_is_internal() to check the value we
want to insert in the tree.

For example:

  * xa_is_advanced()
  * mt_is_reserved()

xa_is_advanced() is used in mtree_insert_range() to prevent inserting an
advanced value for a normal API.
mt_is_reserved() is used in mtree_alloc_range() to prevent inserting reserved
value.

Both check apply to an entry which will be inserted, instead of an entry in
current tree. And they are clearly to inform me the value we want to insert
has special meaning for maple tree and need to be handled carefully.

>This is not friendlier for the audience, it's confusing.
>

The confusing point comes from audience would think the "entry" is already an
internal entry in the tree?

If you really think audience would be misled, I would suggest introduce a new
helper, e.g. mt_is_internal(), just like xa_is_advanced()/mt_is_reserved().

To be honest, an open coded check doesn't looks a good practice.

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2024-08-09  1:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240808043717.10930-1-richard.weiyang@gmail.com>
2024-08-08 16:53 ` Liam R. Howlett
2024-08-09  1:58   ` Wei Yang [this message]
2024-08-09 14:16     ` Liam R. Howlett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240809015852.r3ksdkgivhht3ey3@master \
    --to=richard.weiyang@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox