Lines Matching defs:mt

186 #define mt_lock_is_held(mt)                                             \
187 (!(mt)->ma_external_lock || lock_is_held((mt)->ma_external_lock))
189 #define mt_write_lock_is_held(mt) \
190 (!(mt)->ma_external_lock || \
191 lock_is_held_type((mt)->ma_external_lock, 0))
193 #define mt_set_external_lock(mt, lock) \
194 (mt)->ma_external_lock = &(lock)->dep_map
196 #define mt_on_stack(mt) (mt).ma_external_lock = NULL
199 #define mt_lock_is_held(mt) 1
200 #define mt_write_lock_is_held(mt) 1
201 #define mt_set_external_lock(mt, lock) do { } while (0)
202 #define mt_on_stack(mt) do { } while (0)
259 #define mtree_lock(mt) spin_lock((&(mt)->ma_lock))
261 spin_lock_nested((&(mt)->ma_lock), subclass)
262 #define mtree_unlock(mt) spin_unlock((&(mt)->ma_lock))
314 void *mtree_load(struct maple_tree *mt, unsigned long index);
316 int mtree_insert(struct maple_tree *mt, unsigned long index,
318 int mtree_insert_range(struct maple_tree *mt, unsigned long first,
320 int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp,
323 int mtree_alloc_cyclic(struct maple_tree *mt, unsigned long *startp,
326 int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp,
330 int mtree_store_range(struct maple_tree *mt, unsigned long first,
332 int mtree_store(struct maple_tree *mt, unsigned long index,
334 void *mtree_erase(struct maple_tree *mt, unsigned long index);
336 int mtree_dup(struct maple_tree *mt, struct maple_tree *new, gfp_t gfp);
337 int __mt_dup(struct maple_tree *mt, struct maple_tree *new, gfp_t gfp);
339 void mtree_destroy(struct maple_tree *mt);
340 void __mt_destroy(struct maple_tree *mt);
344 * @mt: Maple Tree.
349 static inline bool mtree_empty(const struct maple_tree *mt)
351 return mt->ma_root == NULL;
469 #define MA_STATE(name, mt, first, end) \
471 .tree = mt, \
590 void mt_dump(const struct maple_tree *mt, enum mt_dump_format format);
593 void mt_validate(struct maple_tree *mt);
757 static inline bool mt_external_lock(const struct maple_tree *mt)
759 return (mt->ma_flags & MT_FLAGS_LOCK_MASK) == MT_FLAGS_LOCK_EXTERN;
764 * @mt: Maple Tree
772 static inline void mt_init_flags(struct maple_tree *mt, unsigned int flags)
774 mt->ma_flags = flags;
775 if (!mt_external_lock(mt))
776 spin_lock_init(&mt->ma_lock);
777 rcu_assign_pointer(mt->ma_root, NULL);
782 * @mt: Maple Tree
788 static inline void mt_init(struct maple_tree *mt)
790 mt_init_flags(mt, 0);
793 static inline bool mt_in_rcu(struct maple_tree *mt)
798 return mt->ma_flags & MT_FLAGS_USE_RCU;
803 * @mt: The Maple Tree
805 static inline void mt_clear_in_rcu(struct maple_tree *mt)
807 if (!mt_in_rcu(mt))
810 if (mt_external_lock(mt)) {
811 WARN_ON(!mt_lock_is_held(mt));
812 mt->ma_flags &= ~MT_FLAGS_USE_RCU;
814 mtree_lock(mt);
815 mt->ma_flags &= ~MT_FLAGS_USE_RCU;
816 mtree_unlock(mt);
822 * @mt: The Maple Tree
824 static inline void mt_set_in_rcu(struct maple_tree *mt)
826 if (mt_in_rcu(mt))
829 if (mt_external_lock(mt)) {
830 WARN_ON(!mt_lock_is_held(mt));
831 mt->ma_flags |= MT_FLAGS_USE_RCU;
833 mtree_lock(mt);
834 mt->ma_flags |= MT_FLAGS_USE_RCU;
835 mtree_unlock(mt);
839 static inline unsigned int mt_height(const struct maple_tree *mt)
841 return (mt->ma_flags & MT_FLAGS_HEIGHT_MASK) >> MT_FLAGS_HEIGHT_OFFSET;
844 void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max);
845 void *mt_find_after(struct maple_tree *mt, unsigned long *index,
847 void *mt_prev(struct maple_tree *mt, unsigned long index, unsigned long min);
848 void *mt_next(struct maple_tree *mt, unsigned long index, unsigned long max);