From 3bc1e116c0a8861447af411ba1af4f07a7316981 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 17 Jul 2020 16:07:53 -0400 Subject: [PATCH] maple_tree: Remove mte_update_rcu_slot and add comments mte_update_rcu_slot is the same as mte_set_rcu_slot, so drop it Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 81 +++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 52 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d629ef533728..3e93f13c90f2 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -44,7 +44,6 @@ unsigned long mt_max[] = { }; #define mt_node_max(x) mt_max[mte_node_type(x)] - unsigned char mt_slots[] = { [maple_dense] = MAPLE_NODE_SLOTS, [maple_sparse_6] = MAPLE_SPARSE6_SLOTS, @@ -100,6 +99,7 @@ unsigned char mt_min_slots[] = { #define mt_min_slot_cnt(x) mt_min_slots[mte_node_type(x)] #define MAPLE_BIG_NODE_SLOTS (MAPLE_NODE_SLOTS * 2 + 1) + struct maple_big_node { struct maple_pnode *parent; struct maple_enode *slot[MAPLE_BIG_NODE_SLOTS]; @@ -620,8 +620,11 @@ static inline struct maple_enode *mas_get_rcu_slot(const struct ma_state *mas, { return mte_get_rcu_slot(mas->node, slot, mas->tree); } -/* Private - * mte_destroy_walk: Free the sub-tree from @mn and below. +/** Private + * mte_destroy_walk() - Free the sub-tree from @mn and below. + * + * @mn - the head of the sub-tree to free. + * @mtree - the maple tree that includes @mn (for type) */ void mte_destroy_walk(struct maple_enode *mn, struct maple_tree *mtree) { @@ -690,7 +693,14 @@ static inline void mat_free(struct ma_topiary *mat, bool recursive) } } - +/** Private + * ma_set_rcu_slot() - Set a nodes rcu slot. + * + * @mn - the maple node for the operation + * @slot - the slot number to set + * @type - the maple node type + * @val - the value to store + */ static inline void ma_set_rcu_slot(struct maple_node *mn, unsigned char slot, enum maple_type type, void *val) { @@ -737,12 +747,20 @@ static inline void ma_set_rcu_slot(struct maple_node *mn, break; } } +/** Private + * mte_set_rcu_slot() - Set an encoded nodes rcu slot. + */ static inline void mte_set_rcu_slot(const struct maple_enode *mn, unsigned char slot, void *val) { ma_set_rcu_slot(mte_to_node(mn), slot, mte_node_type(mn), val); } - +/** Private + * mas_dup_state() - duplicate the internal state of a ma_state. + * + * @dst - the destination to store the state information + * @src - the source of the state information + */ static inline void mas_dup_state(struct ma_state *dst, struct ma_state *src) { dst->tree = src->tree; @@ -753,6 +771,11 @@ static inline void mas_dup_state(struct ma_state *dst, struct ma_state *src) dst->min = src->min; mas_set_slot(dst, mas_get_slot(src)); } +/** Private + * mas_descend() - Descend into the slot stored in the ma_state. + * + * @mas - the maple state. + */ static inline void mas_descend(struct ma_state *mas) { unsigned char slot = mas_get_slot(mas); @@ -763,52 +786,6 @@ static inline void mas_descend(struct ma_state *mas) mas->node = mas_get_rcu_slot(mas, mas_get_slot(mas)); } -static inline void mte_update_rcu_slot(const struct maple_enode *mn, - unsigned char slot, void *val) -{ - enum maple_type type = mte_node_type(mn); - - switch (type) { - case maple_range_64: - case maple_leaf_64: - rcu_assign_pointer(mte_to_node(mn)->mr64.slot[slot], val); - break; - default: - case maple_dense: - rcu_assign_pointer(mte_to_node(mn)->slot[slot], val); - break; - case maple_arange_64: - rcu_assign_pointer(mte_to_node(mn)->ma64.slot[slot], val); - break; - case maple_sparse_6: - rcu_assign_pointer(mte_to_node(mn)->ms6.slot[slot], val); - break; - case maple_sparse_9: - rcu_assign_pointer(mte_to_node(mn)->ms9.slot[slot], val); - break; - case maple_sparse_16: - rcu_assign_pointer(mte_to_node(mn)->ms16.slot[slot], val); - break; - case maple_sparse_21: - rcu_assign_pointer(mte_to_node(mn)->ms21.slot[slot], val); - break; - case maple_sparse_32: - rcu_assign_pointer(mte_to_node(mn)->ms32.slot[slot], val); - break; - case maple_sparse_64: - rcu_assign_pointer(mte_to_node(mn)->ms64.slot[slot], val); - break; - case maple_range_16: - case maple_leaf_16: - rcu_assign_pointer(mte_to_node(mn)->mr16.slot[slot], val); - break; - case maple_range_32: - case maple_leaf_32: - rcu_assign_pointer(mte_to_node(mn)->mr32.slot[slot], val); - break; - } -} - static inline unsigned long ma_get_gap(const struct maple_node *mn, unsigned char gap, enum maple_type type) { @@ -1403,7 +1380,7 @@ static inline void mas_replace(struct ma_state *mas, bool advanced) rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node)); mas->tree->ma_height = mas->depth; } else { - mte_update_rcu_slot(parent, slot, mas->node); + mte_set_rcu_slot(parent, slot, mas->node); } if (!advanced) { -- 2.50.1