mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
UPSTREAM: maple_tree: introduce __mas_set_range()
mas_set_range() resets the node to MAS_START, which will cause a re-walk
of the tree to the range. This is unnecessary when the maple state is
already at the correct location of the write. Add a function that only
sets the range to avoid unnecessary re-walking of the tree.
Link: https://lkml.kernel.org/r/20230724183157.3939892-6-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit c1297987cc)
Bug: 308042511
Change-Id: I9e026d0f103e3aa24b47998be6b83e28e7928540
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
committed by
Suren Baghdasaryan
parent
066d57de87
commit
c52d48818b
@@ -525,6 +525,22 @@ static inline void mas_reset(struct ma_state *mas)
|
|||||||
*/
|
*/
|
||||||
#define mas_for_each(__mas, __entry, __max) \
|
#define mas_for_each(__mas, __entry, __max) \
|
||||||
while (((__entry) = mas_find((__mas), (__max))) != NULL)
|
while (((__entry) = mas_find((__mas), (__max))) != NULL)
|
||||||
|
/**
|
||||||
|
* __mas_set_range() - Set up Maple Tree operation state to a sub-range of the
|
||||||
|
* current location.
|
||||||
|
* @mas: Maple Tree operation state.
|
||||||
|
* @start: New start of range in the Maple Tree.
|
||||||
|
* @last: New end of range in the Maple Tree.
|
||||||
|
*
|
||||||
|
* set the internal maple state values to a sub-range.
|
||||||
|
* Please use mas_set_range() if you do not know where you are in the tree.
|
||||||
|
*/
|
||||||
|
static inline void __mas_set_range(struct ma_state *mas, unsigned long start,
|
||||||
|
unsigned long last)
|
||||||
|
{
|
||||||
|
mas->index = start;
|
||||||
|
mas->last = last;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mas_set_range() - Set up Maple Tree operation state for a different index.
|
* mas_set_range() - Set up Maple Tree operation state for a different index.
|
||||||
@@ -539,9 +555,8 @@ static inline void mas_reset(struct ma_state *mas)
|
|||||||
static inline
|
static inline
|
||||||
void mas_set_range(struct ma_state *mas, unsigned long start, unsigned long last)
|
void mas_set_range(struct ma_state *mas, unsigned long start, unsigned long last)
|
||||||
{
|
{
|
||||||
mas->index = start;
|
__mas_set_range(mas, start, last);
|
||||||
mas->last = last;
|
mas->node = MAS_START;
|
||||||
mas->node = MAS_START;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user