All of lore.kernel.org
 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 2/3] maple_tree: use mas_safe_pivot() to get the pivot range
Date: Wed, 4 Sep 2024 08:01:41 +0000	[thread overview]
Message-ID: <20240904080141.mc6agi55m6wosfev@master> (raw)
In-Reply-To: <kqwpd7oihspvwnfu6fid5r6egcy6l3s5veaswhfee7h3njn5oj@d42pn6kmhxmu>

On Tue, Sep 03, 2024 at 08:41:54PM -0400, Liam R. Howlett wrote:
>nack
>

Would mind giving some reason?

Besides it call an inline function, is this wrong logically?

>* Wei Yang <richard.weiyang@gmail.com> [240830 20:11]:
>> Before modifying data, we need to walk the tree to locate the
>> maple_node. Also we get the range boundary at offset/offset_end.
>> 
>> For the upper boundary at offset, we have defined function
>> mas_safe_pivot() to get it. Let's leverage it.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>>  lib/maple_tree.c | 16 ++++++----------
>>  1 file changed, 6 insertions(+), 10 deletions(-)
>> 
>> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
>> index 85668246f944..17533c246749 100644
>> --- a/lib/maple_tree.c
>> +++ b/lib/maple_tree.c
>> @@ -2185,7 +2185,7 @@ static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
>>  	while (offset < count && mas->index > wr_mas->pivots[offset])
>>  		offset++;
>>  
>> -	wr_mas->r_max = offset < count ? wr_mas->pivots[offset] : mas->max;
>> +	wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type);
>>  	wr_mas->r_min = mas_safe_min(mas, wr_mas->pivots, offset);
>>  	wr_mas->offset_end = mas->offset = offset;
>>  }
>> @@ -3987,11 +3987,9 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas)
>>  		    (mas->end != wr_mas->offset_end) &&
>>  		    !wr_mas->slots[wr_mas->offset_end + 1]) {
>>  			wr_mas->offset_end++;
>> -			if (wr_mas->offset_end == mas->end)
>> -				mas->last = mas->max;
>> -			else
>> -				mas->last = wr_mas->pivots[wr_mas->offset_end];
>> -			wr_mas->end_piv = mas->last;
>> +			wr_mas->end_piv = mas->last =
>> +				mas_safe_pivot(mas, wr_mas->pivots,
>> +					wr_mas->offset_end, wr_mas->type);
>>  		}
>>  	}
>>  
>> @@ -4016,10 +4014,8 @@ static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas)
>>  	       (wr_mas->mas->last > wr_mas->pivots[wr_mas->offset_end]))
>>  		wr_mas->offset_end++;
>>  
>> -	if (wr_mas->offset_end < wr_mas->mas->end)
>> -		wr_mas->end_piv = wr_mas->pivots[wr_mas->offset_end];
>> -	else
>> -		wr_mas->end_piv = wr_mas->mas->max;
>> +	wr_mas->end_piv = mas_safe_pivot(wr_mas->mas, wr_mas->pivots,
>> +				wr_mas->offset_end, wr_mas->type);
>>  
>>  	if (!wr_mas->entry)
>>  		mas_wr_extend_null(wr_mas);
>> -- 
>> 2.34.1
>> 
>> 

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2024-09-04  8:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-31  0:10 [PATCH 1/3] maple_tree: use ma_data_end() in mas_data_end() Wei Yang
2024-08-31  0:10 ` [PATCH 2/3] maple_tree: use mas_safe_pivot() to get the pivot range Wei Yang
2024-09-04  0:41   ` Liam R. Howlett
2024-09-04  8:01     ` Wei Yang [this message]
2024-08-31  0:10 ` [PATCH 3/3] maple_tree: local variable 'count' is not necessary Wei Yang
2024-09-04  0:42   ` Liam R. Howlett
2024-09-03 16:12 ` [PATCH 1/3] maple_tree: use ma_data_end() in mas_data_end() Liam R. Howlett
2024-09-04  0:15   ` Wei Yang
2024-09-04  2:25     ` Liam R. Howlett
2024-09-04  7:58       ` Wei Yang
2024-09-04 14:53         ` Wei Yang
2024-09-05 20:13           ` Liam R. Howlett
2024-09-06  3:44             ` Wei Yang
2024-09-11 23:15               ` Wei Yang
2024-09-13 14:13                 ` Liam R. Howlett
2024-09-14  0:50                   ` Wei Yang

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=20240904080141.mc6agi55m6wosfev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.