Skip to contentSkip to conversation

drm: should break if already found the best size(v2)

PATCH In review Monk Liu 2 participants 2 messages Nov 26, 2018

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm: should break if already found the best size(v2)

some 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.

---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_mm.c +2 -0
index 3cc5fbd..369fd9b 100644
@@ -318,6 +318,8 @@ static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size)
 		if (size <= node->hole_size) {
 			best = node;
 			rb = rb->rb_right;
+			if (size == node->hole_size)
+				break;
 		} else {
 			rb = rb->rb_left;
 		}
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Am 26.11.18 um 08:44 schrieb Monk Liu:

Quoted 16 lines

some 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.

---
  drivers/gpu/drm/drm_mm.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_mm.c +0 -0
index 3cc5fbd..369fd9b 100644

drivers/gpu/drm/drm_mm.c static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size) · line 322

Quoted 5 lines
drivers/gpu/drm/drm_mm.c +2 -0
@@ -318,6 +318,8 @@ static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size)
  		if (size <= node->hole_size) {
  			best = node;
  			rb = rb->rb_right;
+			if (size == node->hole_size)
+				break;

That should probably be refactored like David suggested, e.g. (if (size == node->hole_size)... else if (size < node->hole_size)... else".

Apart from that it looks good to me.

Christian.

drivers/gpu/drm/drm_mm.c static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size) · line 325

Quoted 3 lines
drivers/gpu/drm/drm_mm.c +0 -0
  		} else {
  			rb = rb->rb_left;
  		}

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel