[PATCH] drm: should return upon the best size(v3)
Monk Liu
Monk.Liu at amd.com
Tue Nov 27 03:10:34 UTC 2018
v2:
amend description:
for RB tree traveler we don't need to travel to
the bottom level if already found the equal size node,
thus the search performance can get improved.
v3:
split "<=" to "<" case and "==" case
Tested-by: Rex Zhu <Rex.zhu at amd.com>
Signed-off-by: Monk Liu <Monk.Liu at amd.com>
---
drivers/gpu/drm/drm_mm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 3cc5fbd..c966610 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -315,9 +315,11 @@ static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size)
struct drm_mm_node *node =
rb_entry(rb, struct drm_mm_node, rb_hole_size);
- if (size <= node->hole_size) {
+ if (size < node->hole_size) {
best = node;
rb = rb->rb_right;
+ } else if (size == node->hole_size) {
+ return node;
} else {
rb = rb->rb_left;
}
--
2.7.4
More information about the dri-devel
mailing list