From: Liam R. Howlett Date: Wed, 24 Sep 2025 15:12:36 +0000 (-0400) Subject: renames and comments for code X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=47dcead37b5c40393af413983288acb3318baa45;p=users%2Fjedix%2Flinux-maple.git renames and comments for code Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 7f479852419b..125556c70b0d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2400,7 +2400,7 @@ static inline void cp_leaf_init(struct maple_copy *cp, /* - * rebalance_data_calc() - Calculate the size of the data (1 indexed). + * cp_data_calc() - Calculate the size of the data (1 indexed). * @cp: The maple copy struct with the new data populated. * @l_wr_mas: The maple write state containing the data to the left of the write * @r_wr_mas: The maple write state containing the data to the right of the @@ -2493,7 +2493,18 @@ no_push: sib->end = 0; } -static inline void rebalance_data_calc(struct maple_copy *cp, +/* + * rebalance_data() - Calculate the @cp data, populate @sib if insufficient or + * if the data can be pushed into a sibling. + * @cp: The maple copy node + * @wr_mas: The left write maple state + * @sib: The maple state of the sibling. + * + * Note: @cp->data is a size and not indexed by 0. @sib->end may be set to 0 to + * indicate it will not be used. + * + */ +static inline void rebalance_data(struct maple_copy *cp, struct ma_wr_state *wr_mas, struct ma_state *sib) { cp_data_calc(cp, wr_mas, wr_mas); @@ -2517,9 +2528,16 @@ use_sib: } /* - * cp->data will not be 0 indexed. + * spanning_data() - Calculate the @cp data and populate @sib if insufficient + * @cp: The maple copy node + * @l_wr_mas: The left write maple state + * @r_wr_mas: The right write maple state + * @sib: The maple state of the sibling. + * + * Note: @cp->data is a size and not indexed by 0. @sib->end may be set to 0 to + * indicate it will not be used. */ -static inline void spanning_data_calc(struct maple_copy *cp, +static inline void spanning_data(struct maple_copy *cp, struct ma_wr_state *l_wr_mas, struct ma_wr_state *r_wr_mas, struct ma_state *sib) { @@ -2534,8 +2552,10 @@ static inline void spanning_data_calc(struct maple_copy *cp, } /* - * dst_setup() - Set up multiple destinations for the new data. This is - * called when the node is split or rebalanced. + * dst_setup() - Set up one or more destinations for the new data. + * @cp: The maple copy node + * @mas: The maple state + * @mt: The source node type */ static inline void dst_setup(struct maple_copy *cp, struct ma_state *mas, enum maple_type mt) @@ -2599,7 +2619,12 @@ node_setup: } -static inline void spanning_init_cp_src(struct maple_copy *cp) +/* init_cp_src() - Initialize the next source as @cp itself + * @cp: The maple copy node. + * + * Append the data within the maple_copy node itself to the sources + */ +static inline void init_cp_src(struct maple_copy *cp) { cp->src[cp->s_count].node = ma_mnode_ptr(cp); cp->src[cp->s_count].mt = maple_copy; @@ -2610,7 +2635,13 @@ static inline void spanning_init_cp_src(struct maple_copy *cp) } /* - * src->start and end are 0 indexed + * multi_src_setup() - Set the @cp node up with multiple sources to copy from. + * @cp: The maple copy node + * @l_wr_mas: The left write maple state + * @r_wr_mas: The right write maple state + * @sib: The sibling maple state + * + * Note: @sib->end == 0 indicates no sibling will be used. */ static inline void multi_src_setup(struct maple_copy *cp, struct ma_wr_state *l_wr_mas, @@ -2628,7 +2659,7 @@ void multi_src_setup(struct maple_copy *cp, struct ma_wr_state *l_wr_mas, cp->src[cp->s_count - 1].max = cp->min - 1; } - spanning_init_cp_src(cp); + init_cp_src(cp); /* Copy right either from offset or offset + 1 pending on r_max */ if (r_wr_mas->mas->end != r_wr_mas->offset_end) @@ -2776,7 +2807,7 @@ static inline void cp_dst_to_slots(struct maple_copy *cp, unsigned long min, cp->max = max; } -static inline void rebalance_new_root(struct maple_copy *cp, struct ma_state *mas) +static inline void cp_new_root(struct maple_copy *cp, struct ma_state *mas) { if (cp->d_count != 1) { enum maple_type mt = maple_arange_64; @@ -2787,7 +2818,7 @@ static inline void rebalance_new_root(struct maple_copy *cp, struct ma_state *ma cp->data = cp->d_count; cp->s_count = 0; dst_setup(cp, mas, mt); - spanning_init_cp_src(cp); + init_cp_src(cp); node_copy(mas, cp->src[0].node, 0, cp->data, cp->max, maple_copy, cp->dst[0].node, 0, mt); node_finalise(cp->dst[0].node, mt, cp->end + 1); @@ -2813,7 +2844,7 @@ static bool spanning_ascend(struct maple_copy *cp, struct ma_state *mas, cp_dst_to_slots(cp, l_wr_mas->mas->min, r_wr_mas->mas->max, mas); if (!cp->min && cp->max == ULONG_MAX) { - rebalance_new_root(cp, mas); + cp_new_root(cp, mas); return false; } @@ -2852,7 +2883,7 @@ static void mas_wr_spanning_rebalance(struct ma_state *mas, cp_leaf_init(&cp, mas, l_wr_mas, r_wr_mas); do { - spanning_data_calc(&cp, l_wr_mas, r_wr_mas, &sib); + spanning_data(&cp, l_wr_mas, r_wr_mas, &sib); multi_src_setup(&cp, l_wr_mas, r_wr_mas, &sib); dst_setup(&cp, mas, l_wr_mas->type); cp_data_write(&cp, mas); @@ -2891,7 +2922,7 @@ static inline bool rebalance_ascend(struct maple_copy *cp, cp_dst_to_slots(cp, min, r->max, mas); if (!cp->min && cp->max == ULONG_MAX) { - rebalance_new_root(cp, mas); + cp_new_root(cp, mas); return false; } @@ -3674,7 +3705,7 @@ static bool split_ascend(struct maple_copy *cp, cp_dst_to_slots(cp, min, max, mas); if (!cp->min && cp->max == ULONG_MAX) { - rebalance_new_root(cp, mas); + cp_new_root(cp, mas); return false; } @@ -3697,7 +3728,18 @@ static bool split_ascend(struct maple_copy *cp, return true; } -static void split_data_calc(struct maple_copy *cp, +/* + * split_data() - Calculate the @cp data, populate @sib if the data can be + * pushed into a sibling. + * @cp: The maple copy node + * @wr_mas: The left write maple state + * @sib: The maple state of the sibling. + * + * Note: @cp->data is a size and not indexed by 0. @sib->end may be set to 0 to + * indicate it will not be used. + * + */ +static void split_data(struct maple_copy *cp, struct ma_wr_state *wr_mas, struct ma_state *sib) { cp_data_calc(cp, wr_mas, wr_mas); @@ -3713,7 +3755,7 @@ static void split_data_calc(struct maple_copy *cp, } /* - * mas_wr_split() - Expand one node into two + * mas_wr_split() - Split the data of one node across two nodes. * @wr_mas: The write maple state */ static void mas_wr_split(struct ma_wr_state *wr_mas) @@ -3728,7 +3770,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas) mas = wr_mas->mas; cp_leaf_init(&cp, mas, wr_mas, wr_mas); do { - split_data_calc(&cp, wr_mas, &sib); + split_data(&cp, wr_mas, &sib); multi_src_setup(&cp, wr_mas, wr_mas, &sib); dst_setup(&cp, mas, wr_mas->type); cp_data_write(&cp, mas); @@ -3772,7 +3814,7 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas) mas = wr_mas->mas; cp_leaf_init(&cp, mas, wr_mas, wr_mas); do { - rebalance_data_calc(&cp, wr_mas, &sib); + rebalance_data(&cp, wr_mas, &sib); multi_src_setup(&cp, wr_mas, wr_mas, &sib); dst_setup(&cp, mas, wr_mas->type); cp_data_write(&cp, mas);