diff mbox series

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

Message ID 1543218256-3829-1-git-send-email-Monk.Liu@amd.com (mailing list archive)
State New, archived
Headers show
Series drm: should break if already found the best size(v2) | expand

Commit Message

Liu, Monk Nov. 26, 2018, 7:44 a.m. UTC
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.

Tested-by: Rex Zhu <Rex.zhu@amd.com>
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christian König Nov. 26, 2018, 9:31 a.m. UTC | #1
Am 26.11.18 um 08:44 schrieb Monk Liu:
> 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.
>
> Tested-by: Rex Zhu <Rex.zhu@amd.com>
> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
> ---
>   drivers/gpu/drm/drm_mm.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 3cc5fbd..369fd9b 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -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.

>   		} else {
>   			rb = rb->rb_left;
>   		}
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 3cc5fbd..369fd9b 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -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;
 		}