Skip to contentSkip to conversation

drm: should return upon the best size(v3)

PATCH In review Monk Liu 3 participants 8 messages Nov 27, 2018

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm: should return upon the best size(v3)

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

---
 drivers/gpu/drm/drm_mm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_mm.c +3 -1
index 3cc5fbd..c966610 100644
@@ -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;
 		}
Signature · 6 lines
2.7.4

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

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 11 lines

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

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

#2 lore raw

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 7 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 6 lines

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.

Quoted 6 lines
Quoted 5 lines

v3:
split "<=" to "<" case and "==" case

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Thanks,
Christian.

Quoted 5 lines

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

#3 lore raw

Am 27.11.18 um 11:00 schrieb Christian König:

Quoted 8 lines

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 7 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 6 lines

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.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

v3:
split "<=" to "<" case and "==" case

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Ok figured it out myself by thinking more about it.

A node with the searched size is not necessary the leftmost one, so we would not see all nodes with the searched size and potentially use the wrong one.

Sorry Monk, but Chris is right this optimization is illegal.

Regards,
Christian.

Quoted 10 lines

Thanks,
Christian.

Quoted 5 lines

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

author
#4 lore raw
Quoted 1 line

A node with the searched size is not necessary the leftmost one,

We may have two nodes with the same size, and the one return first will be sure *not* the leftmost one, I aware of that ... But my question is why we need the leftmost one ?

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 8:54 PM
To: Chris Wilson <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 11:00 schrieb Christian König:

Quoted 11 lines

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 10 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 9 lines

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

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Ok figured it out myself by thinking more about it.

A node with the searched size is not necessary the leftmost one, so we would not see all nodes with the searched size and potentially use the wrong one.

Sorry Monk, but Chris is right this optimization is illegal.

Regards,
Christian.

Quoted 10 lines

Thanks,
Christian.

Quoted 5 lines

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

#5 lore raw

Am 27.11.18 um 14:40 schrieb Liu, Monk:

Quoted 3 lines
Quoted 1 line

A node with the searched size is not necessary the leftmost one,

We may have two nodes with the same size, and the one return first will be sure *not* the leftmost one, I aware of that ... But my question is why we need the leftmost one ?

Because the code is designed to iterate over all available nodes. The size is just the primary criteria to judge on.

If we won't return all nodes with the same size we won't necessary find a fitting one.

See how the code is used in drm_mm_insert_node_in_range().

Christian.

Quoted 42 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 8:54 PM
To: Chris Wilson <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 11:00 schrieb Christian König:

Quoted 8 lines

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 7 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 6 lines

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.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

v3:
split "<=" to "<" case and "==" case

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Ok figured it out myself by thinking more about it.

A node with the searched size is not necessary the leftmost one, so we would not see all nodes with the searched size and potentially use the wrong one.

Sorry Monk, but Chris is right this optimization is illegal.

Regards,
Christian.

Quoted 8 lines

Thanks,
Christian.

Quoted 5 lines

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

Quoted 4 lines

_______________________________________________
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

author
#6 lore raw

The logic this patch change is only for "best_hole" which is only get called with " DRM_MM_INSERT_BEST", In drm_mm_insert_node_in_range(), is there other aspect also need calculation and judge for the mode " DRM_MM_INSERT_BEST" ??

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 9:48 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; Chris Wilson <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 14:40 schrieb Liu, Monk:

Quoted 3 lines
Quoted 1 line

A node with the searched size is not necessary the leftmost one,

We may have two nodes with the same size, and the one return first will be sure *not* the leftmost one, I aware of that ... But my question is why we need the leftmost one ?

Because the code is designed to iterate over all available nodes. The size is just the primary criteria to judge on.

If we won't return all nodes with the same size we won't necessary find a fitting one.

See how the code is used in drm_mm_insert_node_in_range().

Christian.

Quoted 43 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 8:54 PM
To: Chris Wilson <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 11:00 schrieb Christian König:

Quoted 8 lines

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 7 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 6 lines

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.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

v3:
split "<=" to "<" case and "==" case

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Ok figured it out myself by thinking more about it.

A node with the searched size is not necessary the leftmost one, so we would not see all nodes with the searched size and potentially use the wrong one.

Sorry Monk, but Chris is right this optimization is illegal.

Regards,
Christian.

Quoted 8 lines

Thanks,
Christian.

Quoted 5 lines

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

Quoted 4 lines

_______________________________________________
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

author
#7 lore raw

Oh, yeah ... I find one aspect, we need to consider "range_start" and "range_end"

Yeah, you guys are right, cool

/Monk

-----Original Message-----
From: Liu, Monk
Sent: Tuesday, November 27, 2018 10:10 PM
To: Koenig, Christian <[email protected]>; Chris Wilson <[email protected]>; [email protected]
Subject: RE: [PATCH] drm: should return upon the best size(v3)

The logic this patch change is only for "best_hole" which is only get called with " DRM_MM_INSERT_BEST", In drm_mm_insert_node_in_range(), is there other aspect also need calculation and judge for the mode " DRM_MM_INSERT_BEST" ??

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 9:48 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; Chris Wilson <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 14:40 schrieb Liu, Monk:

Quoted 3 lines
Quoted 1 line

A node with the searched size is not necessary the leftmost one,

We may have two nodes with the same size, and the one return first will be sure *not* the leftmost one, I aware of that ... But my question is why we need the leftmost one ?

Because the code is designed to iterate over all available nodes. The size is just the primary criteria to judge on.

If we won't return all nodes with the same size we won't necessary find a fitting one.

See how the code is used in drm_mm_insert_node_in_range().

Christian.

Quoted 43 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, November 27, 2018 8:54 PM
To: Chris Wilson <[email protected]>; Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 11:00 schrieb Christian König:

Quoted 8 lines

Am 27.11.18 um 10:20 schrieb Chris Wilson:

Quoted 7 lines

Quoting Monk Liu (2018-11-27 03:10:34)

Quoted 6 lines

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.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

v3:
split "<=" to "<" case and "==" case

Still fundamentally broken.

Can you explain that further? Do we need to return the deepest hole of the right size because the following algorithm depends on that?

Ok figured it out myself by thinking more about it.

A node with the searched size is not necessary the leftmost one, so we would not see all nodes with the searched size and potentially use the wrong one.

Sorry Monk, but Chris is right this optimization is illegal.

Regards,
Christian.

Quoted 8 lines

Thanks,
Christian.

Quoted 5 lines

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

Quoted 4 lines

_______________________________________________
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