[PATCH 3/4] maple_tree: copy to mt_pivot_count() instead of mt_slot_count()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mas_mab_cp() copy a maple_node's range inclusively, and the maximum
valid data index is (mt_slot_count() - 1) instead of mt_slot_count().

But if using (mt_slot_count() - 1) directly, it would have more
instructions.  The good news is we have defined mt_pivot_count() ==
(mt_slot_count - 1), except for maple_dense node. And mas_mab_cp()
doesn't handle maple_dense node. So it is safe to use it.

By doing so have almost identical generated code:

Current:

  lib/maple_tree.c:2209: 	mas_mab_cp(mast->orig_r, 0, mt_slot_count(mast->orig_r->node),
	movl	%esi, (%esp)	# _135,
	movl	-88(%ebp), %eax	# %sfp, _137
	movzbl	mt_slots(%edx), %ecx	# mt_slots[_142], mt_slots[_142]
	xorl	%edx, %edx	#
	movl	%eax, 4(%esp)	# _137,
	movl	%ebx, %eax	# _138,
	call	mas_mab_cp	#

After applying this patch:

  lib/maple_tree.c:2209: 	mas_mab_cp(mast->orig_r, 0, mt_pivot_count(mast->orig_r->node),
	movl	%esi, (%esp)	# _135,
	movl	-88(%ebp), %eax	# %sfp, _137
	movzbl	mt_pivots(%edx), %ecx	# mt_pivots[_142], mt_pivots[_142]
	xorl	%edx, %edx	#
	movl	%eax, 4(%esp)	# _137,
	movl	%ebx, %eax	# _138,
	call	mas_mab_cp	#

The difference is we access mt_pivots to get ecx instead of mt_slots,
which doesn't expect performance difference.

Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
---
 lib/maple_tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 8ff075645f21..bb4183b973d4 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2211,7 +2211,7 @@ static inline void mast_rebalance_next(struct maple_subtree_state *mast)
 {
 	unsigned char b_end = mast->bn->b_end;
 
-	mas_mab_cp(mast->orig_r, 0, mt_slot_count(mast->orig_r->node),
+	mas_mab_cp(mast->orig_r, 0, mt_pivot_count(mast->orig_r->node),
 		   mast->bn, b_end);
 	mast->orig_r->last = mast->orig_r->max;
 }
@@ -2692,7 +2692,7 @@ static inline void mast_combine_cp_right(struct maple_subtree_state *mast)
 		return;
 
 	mas_mab_cp(mast->orig_r, mast->orig_r->offset + 1,
-		   mt_slot_count(mast->orig_r->node), mast->bn,
+		   mt_pivot_count(mast->orig_r->node), mast->bn,
 		   mast->bn->b_end);
 	mast->orig_r->last = mast->orig_r->max;
 }
@@ -2963,7 +2963,7 @@ static inline int mas_rebalance(struct ma_state *mas,
 	l_mas = r_mas = *mas;
 
 	if (mas_next_sibling(&r_mas)) {
-		mas_mab_cp(&r_mas, 0, mt_slot_count(r_mas.node), b_node, b_end);
+		mas_mab_cp(&r_mas, 0, mt_pivot_count(r_mas.node), b_node, b_end);
 		r_mas.last = r_mas.index = r_mas.max;
 	} else {
 		mas_prev_sibling(&l_mas);
-- 
2.34.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux