From: Liam R. Howlett Date: Thu, 3 Sep 2020 00:36:22 +0000 (-0400) Subject: maple_tree: Add newlines after functions X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=23b3f1935237f6af7ed1c95820205506bd58c5fc;p=users%2Fjedix%2Flinux-maple.git maple_tree: Add newlines after functions Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 37097609db76..ddf3ab60405b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -179,6 +179,7 @@ static inline bool mte_is_dense(const struct maple_enode *entry) { return ma_is_dense(mte_node_type(entry)); } + static inline bool ma_is_leaf(const enum maple_type type) { return type < maple_range_16; @@ -202,14 +203,17 @@ static inline bool mt_is_empty(const void *entry) { return !entry; } + static inline void mas_set_err(struct ma_state *mas, long err) { mas->node = MA_ERROR(err); } + static inline bool mas_is_ptr(struct ma_state *mas) { return mas->node == MAS_ROOT; } + static inline bool mas_is_start(struct ma_state *mas) { return mas->node == MAS_START; @@ -230,14 +234,17 @@ static inline bool mas_searchable(struct ma_state *mas) return true; } + static inline struct maple_node *mte_to_node(const struct maple_enode *entry) { return (struct maple_node *)((unsigned long)entry & ~127); } + static inline struct maple_topiary *mte_to_mat(const struct maple_enode *entry) { return (struct maple_topiary *)((unsigned long)entry & ~127); } + static inline struct maple_node *mas_mn(const struct ma_state *mas) { return mte_to_node(mas->node); @@ -247,6 +254,7 @@ static inline void mte_set_node_dead(struct maple_enode *mn) { mte_to_node(mn)->parent = ma_parent_ptr(mte_to_node(mn)); } + static inline void mte_free(struct maple_enode *enode) { ma_free_rcu(mte_to_node(enode)); @@ -261,6 +269,7 @@ static inline void *mte_mk_root(const struct maple_enode *node) { return (void *)((unsigned long)node | 2); } + static inline void *mte_safe_root(const struct maple_enode *node) { return (void *)((unsigned long)node & ~2); @@ -498,16 +507,19 @@ static inline unsigned long ma_get_pivot(const struct maple_node *mn, return 0; } } + static inline unsigned long _mte_get_pivot(const struct maple_enode *mn, unsigned char slot, enum maple_type type) { return ma_get_pivot(mte_to_node(mn), slot, type); } + static inline unsigned long mte_get_pivot(const struct maple_enode *mn, unsigned char slot) { return _mte_get_pivot(mn, slot, mte_node_type(mn)); } + static inline unsigned long _mas_get_safe_pivot(const struct ma_state *mas, unsigned char slot, enum maple_type type) { @@ -582,6 +594,7 @@ static inline void ma_set_pivot(struct maple_node *mn, unsigned char slot, break; } } + static inline void mte_set_pivot(struct maple_enode *mn, unsigned char slot, unsigned long val) { @@ -620,6 +633,7 @@ static inline void __rcu **ma_get_slots(struct maple_node *mn, return mn->mr32.slot; } } + static inline struct maple_enode *ma_get_rcu_slot( const struct maple_node *mn, unsigned char slot, enum maple_type type, struct maple_tree *mtree) @@ -671,6 +685,7 @@ static inline struct maple_enode *_mte_get_rcu_slot( { return ma_get_rcu_slot(mte_to_node(mn), slot, type, mtree); } + static inline struct maple_enode *mte_get_rcu_slot(const struct maple_enode *mn, unsigned char slot, struct maple_tree *mtree) { @@ -832,6 +847,7 @@ static inline unsigned long ma_get_gap(const struct maple_node *mn, return 0; } } + static inline unsigned long mte_get_gap(const struct maple_enode *mn, unsigned char gap) { @@ -937,6 +953,7 @@ static inline struct maple_node *mas_next_alloc(struct ma_state *ms) return mn; } + static inline void mas_push_node(struct ma_state *mas, struct maple_enode *used) { struct maple_node *reuse = mte_to_node(used); @@ -961,6 +978,7 @@ static inline void mas_push_node(struct ma_state *mas, struct maple_enode *used) BUG_ON(!mas_get_alloc_cnt(mas)); } + static inline void mas_node_node(struct ma_state *ms, gfp_t gfp) { struct maple_node *mn, *smn; @@ -1046,6 +1064,7 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp) mas->node = MAS_START; return true; } + static inline struct maple_node *mas_node_cnt(struct ma_state *mas, int count) { int allocated = mas_get_alloc_cnt(mas); @@ -1213,6 +1232,7 @@ static inline unsigned long mas_max_gap(struct ma_state *mas) return max_gap; } + static inline unsigned long mas_find_gap(struct ma_state *mas) { if (mte_is_leaf(mas->node)) @@ -1863,6 +1883,7 @@ static inline void mast_rebalance_prev(struct maple_subtree_state *mast, mast->bn->b_end = end + 1 + b_end; mas_set_offset(mast->l, mas_offset(mast->l) + end + 1); } + static inline bool mast_sibling_rebalance_left(struct maple_subtree_state *mast) { struct maple_enode *old_r = mast->orig_r->node; @@ -2143,6 +2164,7 @@ static inline void mast_set_split_parents(struct maple_subtree_state *mast, // Set right parent. mas_set_split_parent(mast->r, l, r, &slot, split); } + static inline void mas_wmb_replace(struct ma_state *mas, struct ma_topiary *free, struct ma_topiary *destroy) @@ -2166,6 +2188,7 @@ static inline void mas_wmb_replace(struct ma_state *mas, mas_update_gap(mas); } + static inline void mast_new_root(struct maple_subtree_state *mast, struct ma_state *mas) { @@ -2251,6 +2274,7 @@ static inline bool mast_sufficient(struct maple_subtree_state *mast) return false; } + static inline bool mast_overflow(struct maple_subtree_state *mast) { if (mast->bn->b_end >= mt_slot_count(mast->orig_l->node)) @@ -2386,6 +2410,7 @@ new_root: mas_wmb_replace(mas, &free, &destroy); return mast->bn->b_end; } + static inline int mas_cnt_positive(struct ma_state *mas) { if (mas->full_cnt < 0) @@ -2477,6 +2502,7 @@ static inline bool mas_split_final_node(struct maple_subtree_state *mast, return _mas_split_final_node(mast, mas, height); } + static inline void mast_split_fill_bnode(struct maple_subtree_state *mast, struct ma_state *mas, unsigned char skip) @@ -2664,6 +2690,7 @@ static inline int mas_split(struct ma_state *mas, mas_wmb_replace(mas, mast.free, NULL); return 1; } + static inline bool mas_reuse_node(struct ma_state *mas, struct maple_big_node *bn, unsigned char end) @@ -2689,6 +2716,7 @@ static inline bool mas_reuse_node(struct ma_state *mas, return true; } + static inline int mas_commit_b_node(struct ma_state *mas, struct maple_big_node *b_node, unsigned char end) @@ -2759,6 +2787,7 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry) mas_set_height(mas); return slot; } + static inline int ma_root_ptr(struct ma_state *mas, void *entry, void *contents, bool overwrite) { @@ -2874,6 +2903,7 @@ static inline bool mas_node_walk(struct ma_state *mas, enum maple_type type, mas_set_offset(mas, i); return ret; } + static inline void mas_cnt_full(struct ma_state *mas) { if (mas->full_cnt < 0) @@ -2881,6 +2911,7 @@ static inline void mas_cnt_full(struct ma_state *mas) else mas->full_cnt++; } + static inline void mas_cnt_empty(struct ma_state *mas) { if (mas->full_cnt > 0) @@ -3132,6 +3163,7 @@ static inline bool mas_can_append(struct ma_state *mas, return false; } + static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite) { unsigned long r_max, r_min; @@ -3213,6 +3245,7 @@ spanning_store: exists: return content; } + void *mas_store(struct ma_state *mas, void *entry) { if (mas->index <= mas->last) @@ -3222,6 +3255,7 @@ void *mas_store(struct ma_state *mas, void *entry) return NULL; } + static inline int mas_dead_node(struct ma_state *mas, unsigned long index); /* * mas_prev_node() - Find the prev non-null entry at the same level in the @@ -3888,6 +3922,7 @@ static inline bool mas_rewind_node(struct ma_state *mas) mas_set_offset(mas, --slot); return true; } + static inline void mas_rev_awalk(struct ma_state *mas, unsigned long size) { struct maple_enode *last = NULL; @@ -3945,6 +3980,7 @@ static inline bool mas_skip_node(struct ma_state *mas) mas->max = mte_get_pivot(mas->node, slot); return true; } + static inline void mas_awalk(struct ma_state *mas, unsigned long size) { struct maple_enode *last = NULL; @@ -4012,6 +4048,7 @@ void mas_set_fwd_index(struct ma_state *mas, unsigned long size) mas->index = min; mas->last = mas->index + size - 1; } + void mas_set_rev_index(struct ma_state *mas, unsigned long size) { unsigned long gap_max = mas->max; // in-tree gap. @@ -4030,6 +4067,7 @@ void mas_set_rev_index(struct ma_state *mas, unsigned long size) mas->last = gap_max; mas->index = mas->last - size + 1; } + static void _mas_empty_or_single_empty_area(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size, bool fwd) @@ -4050,6 +4088,7 @@ static void _mas_empty_or_single_empty_area(struct ma_state *mas, mas->index = max; } + static inline int _mas_get_empty_area(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size, bool forward) @@ -4092,6 +4131,7 @@ int mas_get_empty_area(struct ma_state *mas, unsigned long min, { return _mas_get_empty_area(mas, min, max, size, true); } + int mas_get_empty_area_rev(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size) { @@ -4319,6 +4359,7 @@ void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max, return entry; } + void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max) { return _mt_find(mt, index, max, true); @@ -4427,6 +4468,7 @@ static inline struct maple_enode *mas_dup_node(struct ma_state *oldmas, memcpy(node, mas_mn(oldmas), sizeof(struct maple_node)); return mt_mk_node(node, mte_node_type(oldmas->node)); } + static inline void mas_dup_alloc(struct ma_state *mas, int *node_cnt) { @@ -4522,6 +4564,7 @@ dup_children: mas_adopt_children(mas, mas->node); } } + void _mas_dup_tree(struct ma_state *oldmas, struct ma_state *mas, int *node_cnt) { if (!xa_is_node(oldmas->tree->ma_root)) { @@ -4557,6 +4600,7 @@ retry_dup_children: mas_adopt_children(mas, mas->node); } } + void mas_dup_tree(struct ma_state *oldmas, struct ma_state *mas) { int node_cnt = 0; @@ -4660,6 +4704,7 @@ void __init maple_tree_init(void) sizeof(struct maple_node), sizeof(struct maple_node), SLAB_PANIC, NULL); } + void mtree_init(struct maple_tree *mt, unsigned int ma_flags) { spin_lock_init(&mt->ma_lock); @@ -4780,6 +4825,7 @@ retry: mtree_unlock(mas.tree); return ret; } + int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, void *entry, unsigned long size, unsigned long min, unsigned long max, gfp_t gfp) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 27adfefa07b1..0170ce4d5178 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -32,6 +32,7 @@ static int mtree_test_store_range(struct maple_tree *mt, unsigned long start, { return mtree_store_range(mt, start, end, ptr, GFP_KERNEL); } + static int mtree_test_insert_range(struct maple_tree *mt, unsigned long start, unsigned long end, void *ptr) { @@ -81,6 +82,7 @@ static noinline void check_mtree_alloc_rrange(struct maple_tree *mt, MT_BUG_ON(mt, result != expected); } + static noinline void check_load(struct maple_tree *mt, unsigned long index, void *ptr) { @@ -135,6 +137,7 @@ static noinline void check_erase(struct maple_tree *mt, unsigned long index, { MT_BUG_ON(mt, mtree_test_erase(mt, index) != ptr); } + static noinline void check_dup_insert(struct maple_tree *mt, unsigned long index, void *ptr) { @@ -390,11 +393,13 @@ static noinline void check_lb_not_empty(struct maple_tree *mt) mtree_destroy(mt); } + static noinline void check_lower_bound_split(struct maple_tree *mt) { MT_BUG_ON(mt, !mtree_empty(mt)); check_lb_not_empty(mt); } + static noinline void check_upper_bound_split(struct maple_tree *mt) { unsigned long i, j; @@ -414,6 +419,7 @@ static noinline void check_upper_bound_split(struct maple_tree *mt) } mtree_destroy(mt); } + static noinline void check_mid_split(struct maple_tree *mt) { unsigned long huge = 8000UL * 1000 * 1000; @@ -953,6 +959,7 @@ int mas_ce2_over_cnt(struct ma_state *mas_start, struct ma_state *mas_end, return cnt; } + static noinline void check_erase2_testset(struct maple_tree *mt, unsigned long *set, unsigned long size) { @@ -32149,6 +32156,7 @@ static noinline void check_prev_entry(struct maple_tree *mt) mtree_destroy(mt); } + static noinline void check_gap_combining(struct maple_tree *mt) { struct maple_enode *mn1, *mn2; @@ -32432,6 +32440,7 @@ static void check_dup_tree(struct maple_tree *oldmt) check_load(&mt, max + 1, NULL); mtree_destroy(&mt); } + static DEFINE_MTREE(tree); static int maple_tree_seed(void)