Skip to contentSkip to conversation

drm: should break if already get the best size

PATCH In review Monk Liu 6 participants 12 messages Nov 22, 2018 – Nov 26, 2018 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm: should break if already get the best size

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

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

PATCH 1/1 drm: should break if already get the best size

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Monk Liu
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH] drm: should break if already get the best size

---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)
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;
 		} else {
 			rb = rb->rb_left;
 		}

--
2.7.4

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

#2 lore raw

PATCH 1/1 drm: should break if already get the best size

In reply to Monk Liu

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Monk Liu
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH] drm: should break if already get the best size

---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)
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;
 		} else {
 			rb = rb->rb_left;
 		}

--
2.7.4

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

#3 lore raw

Quoting Liu, Monk (2018-11-23 08:02:11)

Quoted 18 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Monk Liu
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH] drm: should break if already get the best size

---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)

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;

No. The point is to find the first in the chain that matches because not every node is suitable. By not checking all best_sizes you may end up skipping the perfect match.
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

What do you mean the first in the chain ? and also can you explain the " perfect match." ? thanks

Assume there is couple nodes equal to the size you requested, without this patch it will traveler to the bottom level of the RB tree and gives you the node that close to the bottom level, which takes more time compared with break on the first node, but anyway you eventually get the node with the same size

if there is no node that equal to the size you requested, without or with my patch the logic is totally the same.

/Monk
-----Original Message-----
From: Chris Wilson <[email protected]>
Sent: Friday, November 23, 2018 5:03 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: FW: [PATCH] drm: should break if already get the best size

Quoting Liu, Monk (2018-11-23 08:02:11)

Quoted 20 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Monk Liu
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH] drm: should break if already get the best size

---
 drivers/gpu/drm/drm_mm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_mm.c index renamed from drivers/gpu/drm/drm_mm.c +0 -0

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;

No. The point is to find the first in the chain that matches because not every node is suitable. By not checking all best_sizes you may end up skipping the perfect match. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Quoting Liu, Monk (2018-11-23 09:11:02)

Quoted 4 lines

What do you mean the first in the chain ? and also can you explain the " perfect match." ? thanks

Assume there is couple nodes equal to the size you requested, without this patch it will traveler to the bottom level of the RB tree and gives you the node that close to the bottom level, which takes more time compared with break on the first node, but anyway you eventually get the node with the same size

Size is but of one many checks the node must pass before being returned. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

There is no checks at all in this best_hole() ... can you review the patch again ?

/Monk
-----Original Message-----
From: Chris Wilson <[email protected]>
Sent: Friday, November 23, 2018 5:34 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: RE: FW: [PATCH] drm: should break if already get the best size

Quoting Liu, Monk (2018-11-23 09:11:02)

Quoted 8 lines

What do you mean the first in the chain ? and also can you explain the " perfect match." ? thanks

Assume there is couple nodes equal to the size you requested, without this patch it will traveler to the bottom level of the RB tree and gives you the node that close to the bottom level, which takes more time compared with break on the first node, but anyway you eventually get the node with the same size

Size is but of one many checks the node must pass before being returned. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
In reply to Liu, Monk

Totally find to me, but can we change it a bit like:

if (size < node->hole_size) {
best = node;
rb = rb->rb_right;
} else if (size > node->hole_size){
rb = rb->rb_left;

  		} else {
			break;
		}

-David

Quoted 28 lines · Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Monk Liu
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>
Subject: [PATCH] drm: should break if already get the best size

---
  drivers/gpu/drm/drm_mm.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_mm.c +2 -1
@@ -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;
  		}
--

2.7.4

Quoted 8 lines

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

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

A message that is not in the archive (sent off-list or not yet received): 1542889986-13261-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

Tested-by
#9 lore raw

Without this patch, if we search node via rb tree.

For example: we insert 9999 different node with rand size, size range in (1-9999).

the key in root node is 5587.

if we try to find the node with key equal to 5587 or 7381,

Loop:
node->key is 5587
node->key is 2273
node->key is 3706
node->key is 4892
node->key is 5296
node->key is 5461
node->key is 5519
node->key is 5549
node->key is 5570
node->key is 5581
node->key is 5584
node->key is 5585
node->key is 5586
node->key is 5586

Find the best node, key is 5587 (Loop 14 levels)

Loop:
node->key is 5587
node->key is 7381
node->key is 6474
node->key is 7034
node->key is 7228
node->key is 7314
node->key is 7339
node->key is 7349
node->key is 7372
node->key is 7377
node->key is 7378
node->key is 7379
node->key is 7379

find the best node, key is 7381. (Loop 13 levels)

With this patch:

we don't need to go down if we found the right node that size equal to we needed.

Best Regards
Rex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Monk Liu <[email protected]>
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH] drm: should break if already get the best size

---
 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;
                 }

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.

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

#10 lore raw

PATCH 1/1 drm: should break if already get the best size

Hi Chris

Please check the sanity test of the patch from Rex

/Monk
From: Zhu, Rex
Sent: Friday, November 23, 2018 5:45 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should break if already get the best size

Without this patch, if we search node via rb tree.

For example: we insert 9999 different node with rand size, size range in (1-9999).

the key in root node is 5587.

if we try to find the node with key equal to 5587 or 7381,

Loop:
node->key is 5587
node->key is 2273
node->key is 3706
node->key is 4892
node->key is 5296
node->key is 5461
node->key is 5519
node->key is 5549
node->key is 5570
node->key is 5581
node->key is 5584
node->key is 5585
node->key is 5586
node->key is 5586

Find the best node, key is 5587 (Loop 14 levels)

Loop:
node->key is 5587
node->key is 7381
node->key is 6474
node->key is 7034
node->key is 7228
node->key is 7314
node->key is 7339
node->key is 7349
node->key is 7372
node->key is 7377
node->key is 7378
node->key is 7379
node->key is 7379

find the best node, key is 7381. (Loop 13 levels)

With this patch:

we don't need to go down if we found the right node that size equal to we needed.

Best Regards
Rex

________________________________
From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Monk Liu <[email protected]<mailto:[email protected]>>
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]<mailto:[email protected]>
Cc: Liu, Monk
Subject: [PATCH] drm: should break if already get the best size

---
 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;
                 }

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected]<mailto:[email protected]>. You can subscribe to the list, or change your existing subscription, in the sections below.

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

A message that is not in the archive (sent off-list or not yet received): BN7PR12MB2770EAF767A7AFC6CE0A6ADCFBD40-Zx/IyJUqfGIGZxRL2V81NwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

Tested-by Rex Zhu
#12 lore raw

Please add a proper patch description.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Zhu, Rex <[email protected]>
Sent: Friday, November 23, 2018 4:44:31 AM
To: Liu, Monk; [email protected]
Subject: Re: [PATCH] drm: should break if already get the best size

Without this patch, if we search node via rb tree.

For example: we insert 9999 different node with rand size, size range in (1-9999).

the key in root node is 5587.

if we try to find the node with key equal to 5587 or 7381,

Loop:
node->key is 5587
node->key is 2273
node->key is 3706
node->key is 4892
node->key is 5296
node->key is 5461
node->key is 5519
node->key is 5549
node->key is 5570
node->key is 5581
node->key is 5584
node->key is 5585
node->key is 5586
node->key is 5586

Find the best node, key is 5587 (Loop 14 levels)

Loop:
node->key is 5587
node->key is 7381
node->key is 6474
node->key is 7034
node->key is 7228
node->key is 7314
node->key is 7339
node->key is 7349
node->key is 7372
node->key is 7377
node->key is 7378
node->key is 7379
node->key is 7379

find the best node, key is 7381. (Loop 13 levels)

With this patch:

we don't need to go down if we found the right node that size equal to we needed.

Best Regards
Rex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Monk Liu <[email protected]>
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH] drm: should break if already get the best size

---
 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;
                 }

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.

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

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB18098F780A02FF1CEAE32D07F7D40-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author Tested-by Rex Zhu
#14 lore raw

Ok, will send a v2 version with description

From: Deucher, Alexander
Sent: Saturday, November 24, 2018 3:34 AM
To: Zhu, Rex <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should break if already get the best size

Please add a proper patch description.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Zhu, Rex <[email protected]<mailto:[email protected]>>
Sent: Friday, November 23, 2018 4:44:31 AM
To: Liu, Monk; [email protected]<mailto:amd-gfx-PD4FTy7X32nrcLQh/[email protected]>
Subject: Re: [PATCH] drm: should break if already get the best size

Without this patch, if we search node via rb tree.

For example: we insert 9999 different node with rand size, size range in (1-9999).

the key in root node is 5587.

if we try to find the node with key equal to 5587 or 7381,

Loop:
node->key is 5587
node->key is 2273
node->key is 3706
node->key is 4892
node->key is 5296
node->key is 5461
node->key is 5519
node->key is 5549
node->key is 5570
node->key is 5581
node->key is 5584
node->key is 5585
node->key is 5586
node->key is 5586

Find the best node, key is 5587 (Loop 14 levels)

Loop:
node->key is 5587
node->key is 7381
node->key is 6474
node->key is 7034
node->key is 7228
node->key is 7314
node->key is 7339
node->key is 7349
node->key is 7372
node->key is 7377
node->key is 7378
node->key is 7379
node->key is 7379

find the best node, key is 7381. (Loop 13 levels)

With this patch:

we don't need to go down if we found the right node that size equal to we needed.

Best Regards
Rex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Monk Liu <[email protected]<mailto:[email protected]>>
Sent: Thursday, November 22, 2018 8:33 PM
To: [email protected]<mailto:[email protected]>
Cc: Liu, Monk
Subject: [PATCH] drm: should break if already get the best size

---
 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;
                 }

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected]<mailto:[email protected]>. You can subscribe to the list, or change your existing subscription, in the sections below.

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