linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org,
	linux-mm@kvack.org, akpm@linux-foundation.org,
	liam.howlett@oracle.com, willy@infradead.org, surenb@google.com
Subject: Re: [PATCH v4 04/17] maple_tree: introduce mas_wr_store_type()
Date: Wed, 25 Sep 2024 02:04:31 +0000	[thread overview]
Message-ID: <20240925020431.joykmu4zzahoglcl@master> (raw)
In-Reply-To: <20240814161944.55347-5-sidhartha.kumar@oracle.com>

On Wed, Aug 14, 2024 at 12:19:31PM -0400, Sidhartha Kumar wrote:

Sorry for a late reply, I just see this change.

>+
>+/*
>+ * mas_wr_store_type() - Set the store type for a given
>+ * store operation.
>+ * @wr_mas: The maple write state
>+ */
>+static inline void mas_wr_store_type(struct ma_wr_state *wr_mas)
>+{
>+	struct ma_state *mas = wr_mas->mas;
>+	unsigned char new_end;
>+
>+	if (unlikely(mas_is_none(mas) || mas_is_ptr(mas))) {
>+		mas->store_type = wr_store_root;
>+		return;
>+	}
>+
>+	if (unlikely(!mas_wr_walk(wr_mas))) {
>+		mas->store_type = wr_spanning_store;
>+		return;
>+	}
>+
>+	/* At this point, we are at the leaf node that needs to be altered. */
>+	mas_wr_end_piv(wr_mas);
>+	if (!wr_mas->entry)
>+		mas_wr_extend_null(wr_mas);
>+
>+	new_end = mas_wr_new_end(wr_mas);
>+	if ((wr_mas->r_min == mas->index) && (wr_mas->r_max == mas->last)) {
>+		mas->store_type = wr_exact_fit;
>+		return;
>+	}
>+
>+	if (unlikely(!mas->index && mas->last == ULONG_MAX)) {
>+		mas->store_type = wr_new_root;
>+		return;
>+	}
>+
>+	/* Potential spanning rebalance collapsing a node */
>+	if (new_end < mt_min_slots[wr_mas->type]) {
>+		if (!mte_is_root(mas->node)) {
>+			mas->store_type = wr_rebalance;
>+			return;
>+		}
>+		mas->store_type = wr_node_store;
>+		return;
>+	}

After this check, we are sure new_end >= mt_min_slots[wr_mas->type].

>+
>+	if (new_end >= mt_slots[wr_mas->type]) {
>+		mas->store_type = wr_split_store;
>+		return;
>+	}
>+
>+	if (!mt_in_rcu(mas->tree) && (mas->offset == mas->end)) {
>+		mas->store_type = wr_append;
>+		return;
>+	}
>+
>+	if ((new_end == mas->end) && (!mt_in_rcu(mas->tree) ||
>+		(wr_mas->offset_end - mas->offset == 1))) {
>+		mas->store_type = wr_slot_store;
>+		return;
>+	}
>+
>+	if (mte_is_root(mas->node) || (new_end >= mt_min_slots[wr_mas->type]) ||
>+		(mas->mas_flags & MA_STATE_BULK)) {

The check (new_end >= mt_min_slots[wr_mas->type]) here seems always be true.

So the if here seems not necessary. Do I miss something?

>+		mas->store_type = wr_node_store;
>+		return;
>+	}
>+
>+	mas->store_type = wr_invalid;
>+	MAS_WARN_ON(mas, 1);
>+}
>+

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2024-09-25  2:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 16:19 [PATCH v4 00/17] Introduce a store type enum for the Maple tree Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 01/17] maple_tree: introduce store_type enum Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 02/17] maple_tree: introduce mas_wr_prealloc_setup() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 03/17] maple_tree: move up mas_wr_store_setup() and mas_wr_prealloc_setup() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 04/17] maple_tree: introduce mas_wr_store_type() Sidhartha Kumar
2024-09-25  2:04   ` Wei Yang [this message]
2024-09-25 19:33     ` Sid Kumar
2024-09-25 19:36       ` Sid Kumar
2024-09-25 22:59         ` Wei Yang
2024-08-14 16:19 ` [PATCH v4 05/17] maple_tree: remove mas_destroy() from mas_nomem() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 06/17] maple_tree: preallocate nodes in mas_erase() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 07/17] maple_tree: use mas_store_gfp() in mtree_store_range() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 08/17] maple_tree: print store type in mas_dump() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 09/17] maple_tree: use store type in mas_wr_store_entry() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 10/17] maple_tree: convert mas_insert() to preallocate nodes Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 11/17] maple_tree: simplify mas_commit_b_node() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 12/17] maple_tree: remove mas_wr_modify() Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 13/17] maple_tree: have mas_store() allocate nodes if needed Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 14/17] maple_tree: remove node allocations from various write helper functions Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 15/17] maple_tree: remove repeated sanity checks from " Sidhartha Kumar
2024-08-14 16:19 ` [PATCH v4 16/17] maple_tree: remove unneeded mas_wr_walk() in mas_store_prealloc() Sidhartha Kumar
2024-10-24  1:20   ` Wei Yang
2024-10-25 19:54     ` Sid Kumar
2024-10-25 23:58       ` Wei Yang
2024-10-29 15:46         ` Sid Kumar
2024-10-31 23:18           ` Wei Yang
2024-08-14 16:19 ` [PATCH v4 17/17] maple_tree: make write helper functions void Sidhartha Kumar

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=20240925020431.joykmu4zzahoglcl@master \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=liam.howlett@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=surenb@google.com \
    --cc=willy@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