All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: should return upon the best size(v3)
@ 2018-11-27  3:10 Monk Liu
  2018-11-27  9:20 ` Chris Wilson
  0 siblings, 1 reply; 8+ messages in thread
From: Monk Liu @ 2018-11-27  3:10 UTC (permalink / raw)
  To: dri-devel; +Cc: Monk Liu

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@amd.com>
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: should return upon the best size(v3)
  2018-11-27  3:10 [PATCH] drm: should return upon the best size(v3) Monk Liu
@ 2018-11-27  9:20 ` Chris Wilson
  2018-11-27 10:00   ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2018-11-27  9:20 UTC (permalink / raw)
  To: dri-devel; +Cc: Monk Liu

Quoting Monk Liu (2018-11-27 03:10:34)
> 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@amd.com>
> Signed-off-by: Monk Liu <Monk.Liu@amd.com>

Still fundamentally broken.
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: should return upon the best size(v3)
  2018-11-27  9:20 ` Chris Wilson
@ 2018-11-27 10:00   ` Christian König
  2018-11-27 12:54     ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2018-11-27 10:00 UTC (permalink / raw)
  To: Chris Wilson, Monk Liu, dri-devel

Am 27.11.18 um 10:20 schrieb Chris Wilson:
> Quoting Monk Liu (2018-11-27 03:10:34)
>> 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@amd.com>
>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
> 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.

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: should return upon the best size(v3)
  2018-11-27 10:00   ` Christian König
@ 2018-11-27 12:54     ` Christian König
  2018-11-27 13:40       ` Liu, Monk
  0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2018-11-27 12:54 UTC (permalink / raw)
  To: Chris Wilson, Monk Liu, dri-devel

Am 27.11.18 um 11:00 schrieb Christian König:
> Am 27.11.18 um 10:20 schrieb Chris Wilson:
>> Quoting Monk Liu (2018-11-27 03:10:34)
>>> 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@amd.com>
>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>> 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.

>
> Thanks,
> Christian.
>
>> -Chris
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] drm: should return upon the best size(v3)
  2018-11-27 12:54     ` Christian König
@ 2018-11-27 13:40       ` Liu, Monk
  2018-11-27 13:48         ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Liu, Monk @ 2018-11-27 13:40 UTC (permalink / raw)
  To: Koenig, Christian, Chris Wilson, dri-devel

> 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 <ckoenig.leichtzumerken@gmail.com> 
Sent: Tuesday, November 27, 2018 8:54 PM
To: Chris Wilson <chris@chris-wilson.co.uk>; Liu, Monk <Monk.Liu@amd.com>; dri-devel@freedesktop.org
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 11:00 schrieb Christian König:
> Am 27.11.18 um 10:20 schrieb Chris Wilson:
>> Quoting Monk Liu (2018-11-27 03:10:34)
>>> 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@amd.com>
>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>> 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.

>
> Thanks,
> Christian.
>
>> -Chris
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: should return upon the best size(v3)
  2018-11-27 13:40       ` Liu, Monk
@ 2018-11-27 13:48         ` Christian König
  2018-11-27 14:10           ` Liu, Monk
  0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2018-11-27 13:48 UTC (permalink / raw)
  To: Liu, Monk, Koenig, Christian, Chris Wilson, dri-devel

Am 27.11.18 um 14:40 schrieb Liu, Monk:
>> 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.

>
>
> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Tuesday, November 27, 2018 8:54 PM
> To: Chris Wilson <chris@chris-wilson.co.uk>; Liu, Monk <Monk.Liu@amd.com>; dri-devel@freedesktop.org
> Subject: Re: [PATCH] drm: should return upon the best size(v3)
>
> Am 27.11.18 um 11:00 schrieb Christian König:
>> Am 27.11.18 um 10:20 schrieb Chris Wilson:
>>> Quoting Monk Liu (2018-11-27 03:10:34)
>>>> 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@amd.com>
>>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>>> 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.
>
>> Thanks,
>> Christian.
>>
>>> -Chris
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] drm: should return upon the best size(v3)
  2018-11-27 13:48         ` Christian König
@ 2018-11-27 14:10           ` Liu, Monk
  2018-11-27 14:13             ` Liu, Monk
  0 siblings, 1 reply; 8+ messages in thread
From: Liu, Monk @ 2018-11-27 14:10 UTC (permalink / raw)
  To: Koenig, Christian, Chris Wilson, dri-devel

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 <ckoenig.leichtzumerken@gmail.com> 
Sent: Tuesday, November 27, 2018 9:48 PM
To: Liu, Monk <Monk.Liu@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Chris Wilson <chris@chris-wilson.co.uk>; dri-devel@freedesktop.org
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 14:40 schrieb Liu, Monk:
>> 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.

>
>
> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Tuesday, November 27, 2018 8:54 PM
> To: Chris Wilson <chris@chris-wilson.co.uk>; Liu, Monk 
> <Monk.Liu@amd.com>; dri-devel@freedesktop.org
> Subject: Re: [PATCH] drm: should return upon the best size(v3)
>
> Am 27.11.18 um 11:00 schrieb Christian König:
>> Am 27.11.18 um 10:20 schrieb Chris Wilson:
>>> Quoting Monk Liu (2018-11-27 03:10:34)
>>>> 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@amd.com>
>>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>>> 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.
>
>> Thanks,
>> Christian.
>>
>>> -Chris
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] drm: should return upon the best size(v3)
  2018-11-27 14:10           ` Liu, Monk
@ 2018-11-27 14:13             ` Liu, Monk
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Monk @ 2018-11-27 14:13 UTC (permalink / raw)
  To: Koenig, Christian, Chris Wilson, dri-devel

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 <Christian.Koenig@amd.com>; Chris Wilson <chris@chris-wilson.co.uk>; dri-devel@freedesktop.org
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 <ckoenig.leichtzumerken@gmail.com>
Sent: Tuesday, November 27, 2018 9:48 PM
To: Liu, Monk <Monk.Liu@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Chris Wilson <chris@chris-wilson.co.uk>; dri-devel@freedesktop.org
Subject: Re: [PATCH] drm: should return upon the best size(v3)

Am 27.11.18 um 14:40 schrieb Liu, Monk:
>> 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.

>
>
> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Tuesday, November 27, 2018 8:54 PM
> To: Chris Wilson <chris@chris-wilson.co.uk>; Liu, Monk 
> <Monk.Liu@amd.com>; dri-devel@freedesktop.org
> Subject: Re: [PATCH] drm: should return upon the best size(v3)
>
> Am 27.11.18 um 11:00 schrieb Christian König:
>> Am 27.11.18 um 10:20 schrieb Chris Wilson:
>>> Quoting Monk Liu (2018-11-27 03:10:34)
>>>> 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@amd.com>
>>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>>> 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.
>
>> Thanks,
>> Christian.
>>
>>> -Chris
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-27 14:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27  3:10 [PATCH] drm: should return upon the best size(v3) Monk Liu
2018-11-27  9:20 ` Chris Wilson
2018-11-27 10:00   ` Christian König
2018-11-27 12:54     ` Christian König
2018-11-27 13:40       ` Liu, Monk
2018-11-27 13:48         ` Christian König
2018-11-27 14:10           ` Liu, Monk
2018-11-27 14:13             ` Liu, Monk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.