You can walk each entry within a range by using mas_for_each(). If you want
to walk each element of the tree then ``0`` and ``ULONG_MAX`` may be used as
the range. If the lock needs to be periodically dropped, see the locking
-section mas_pause().
+section mas_invalidate().
Using a maple state allows mas_next() and mas_prev() to function as if the
tree was a linked list. With such a high branching factor the amortized
the first call, and the previous entry from every subsequent calls.
If the user needs to yield the lock during an operation, then the maple state
-must be paused using mas_pause().
+must be invalidated using mas_invalidate().
There are a few extra interfaces provided when using an allocation tree.
If you wish to search for a gap within a range, then mas_empty_area()
#define MAS_START ((struct maple_enode *)1UL)
#define MAS_ROOT ((struct maple_enode *)5UL)
#define MAS_NONE ((struct maple_enode *)9UL)
-#define MAS_PAUSE ((struct maple_enode *)17UL)
+#define MAS_INVALID ((struct maple_enode *)17UL)
#define MA_ERROR(err) \
((struct maple_enode *)(((unsigned long)err << 2) | 2UL))
bool mas_is_err(struct ma_state *mas);
bool mas_nomem(struct ma_state *mas, gfp_t gfp);
-void mas_pause(struct ma_state *mas);
+void mas_invalidate(struct ma_state *mas);
void maple_tree_init(void);
void mas_destroy(struct ma_state *mas);
int mas_expected_entries(struct ma_state *mas, unsigned long nr_entries);
return mas->node == MAS_NONE;
}
-/* Checks if a mas has been paused */
-static inline bool mas_is_paused(struct ma_state *mas)
+/* Checks if a mas has been invalidated */
+static inline bool mas_is_invalid(struct ma_state *mas)
{
- return mas->node == MAS_PAUSE;
+ return mas->node == MAS_INVALID;
}
void mas_dup_tree(struct ma_state *oldmas, struct ma_state *mas);
static inline void vma_iter_invalidate(struct vma_iterator *vmi)
{
- mas_pause(&vmi->mas);
+ mas_invalidate(&vmi->mas);
}
static inline void vma_iter_set(struct vma_iterator *vmi, unsigned long addr)
if (mas->index > limit) {
mas->index = mas->last = limit;
- mas_pause(mas);
+ mas_invalidate(mas);
return NULL;
}
last = mas->last;
if (mas->index < min) {
mas->index = mas->last = min;
- mas_pause(mas);
+ mas_invalidate(mas);
return NULL;
}
retry:
*/
void *mas_next(struct ma_state *mas, unsigned long max)
{
- if (mas_is_none(mas) || mas_is_paused(mas))
+ if (mas_is_none(mas) || mas_is_invalid(mas))
mas->node = MAS_START;
if (mas_is_start(mas))
if (unlikely(mas_is_ptr(mas)))
return NULL;
- if (mas_is_none(mas) || mas_is_paused(mas))
+ if (mas_is_none(mas) || mas_is_invalid(mas))
mas->node = MAS_START;
if (mas_is_start(mas)) {
EXPORT_SYMBOL_GPL(mt_prev);
/**
- * mas_pause() - Pause a mas_find/mas_for_each to drop the lock.
+ * mas_invalidate() - Pause a mas_find/mas_for_each to drop the lock.
* @mas: The maple state to pause
*
* Some users need to pause a walk and drop the lock they're holding in
* on an entry. Those users should call this function before they drop
* the lock. It resets the @mas to be suitable for the next iteration
* of the loop after the user has reacquired the lock. If most entries
- * found during a walk require you to call mas_pause(), the mt_for_each()
+ * found during a walk require you to call mas_invalidate(), the mt_for_each()
* iterator may be more appropriate.
*
*/
-void mas_pause(struct ma_state *mas)
+void mas_invalidate(struct ma_state *mas)
{
- mas->node = MAS_PAUSE;
+ mas->node = MAS_INVALID;
}
-EXPORT_SYMBOL_GPL(mas_pause);
+EXPORT_SYMBOL_GPL(mas_invalidate);
/**
* mas_find() - On the first call, find the entry at or after mas->index up to
*/
void *mas_find(struct ma_state *mas, unsigned long max)
{
- if (unlikely(mas_is_paused(mas))) {
+ if (unlikely(mas_is_invalid(mas))) {
if (unlikely(mas->last == ULONG_MAX)) {
mas->node = MAS_NONE;
return NULL;
*/
void *mas_find_rev(struct ma_state *mas, unsigned long min)
{
- if (unlikely(mas_is_paused(mas))) {
+ if (unlikely(mas_is_invalid(mas))) {
if (unlikely(mas->last == ULONG_MAX)) {
mas->node = MAS_NONE;
return NULL;
void *entry;
MA_WR_STATE(wr_mas, mas, NULL);
- if (mas_is_none(mas) || mas_is_paused(mas))
+ if (mas_is_none(mas) || mas_is_invalid(mas))
mas->node = MAS_START;
/* Retry unnecessary when holding the write lock. */
}
mas_unlock(&mas);
- /* Test mas_pause */
+ /* Test mas_invalidate */
val = 0;
mas_set(&mas, val);
mas_lock(&mas);
if (!val)
val = 1;
- mas_pause(&mas);
+ mas_invalidate(&mas);
mas_unlock(&mas);
mas_lock(&mas);
}
/* For zero check. */
if (!val)
val = 1;
- mas_pause(&mas);
+ mas_invalidate(&mas);
mas_unlock(&mas);
mas_lock(&mas);
}
mas_set(&mas, 0);
i = 0;
mas_for_each(&mas, val, 1000) {
- mas_pause(&mas);
+ mas_invalidate(&mas);
i++;
}
void *entry = NULL;
unsigned long index = mas->index;
- if (mas_is_none(mas) || mas_is_paused(mas))
+ if (mas_is_none(mas) || mas_is_invalid(mas))
mas->node = MAS_START;
retry:
if (mas_tree_walk(mas, range_min, range_max))