[PATCH] drm: should return upon the best size(v3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
Signed-off-by: Monk Liu <Monk.Liu@xxxxxxx>
---
 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

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux