All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Marek Olšák" <maraeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>
Cc: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx mailing list
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 1/2] drm/amdgpu: return bo itself if userptr is cpu addr of bo (v3)
Date: Thu, 2 Aug 2018 14:20:16 +0800	[thread overview]
Message-ID: <5B62A2A0.5060508@amd.com> (raw)
In-Reply-To: <CAAxE2A4bma0u8R+ggETPoUycC=MTkrs0oUGJFW8kGx__Sf35eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 08/02/2018 08:00 AM, Marek Olšák wrote:
> On Wed, Aug 1, 2018 at 2:29 PM, Christian König
> <christian.koenig@amd.com> wrote:
>> Am 01.08.2018 um 19:59 schrieb Marek Olšák:
>>>
>>> On Wed, Aug 1, 2018 at 1:52 PM, Christian König
>>> <christian.koenig@amd.com> wrote:
>>>>
>>>> Am 01.08.2018 um 19:39 schrieb Marek Olšák:
>>>>>
>>>>> On Wed, Aug 1, 2018 at 2:32 AM, Christian König
>>>>> <christian.koenig@amd.com> wrote:
>>>>>>
>>>>>> Am 01.08.2018 um 00:07 schrieb Marek Olšák:
>>>>>>>
>>>>>>> Can this be implemented as a wrapper on top of libdrm? So that the
>>>>>>> tree (or hash table) isn't created for UMDs that don't need it.
>>>>>>
>>>>>>
>>>>>> No, the problem is that an application gets a CPU pointer from one API
>>>>>> and
>>>>>> tries to import that pointer into another one.
>>>>>>
>>>>>> In other words we need to implement this independent of the UMD who
>>>>>> mapped
>>>>>> the BO.
>>>>>
>>>>> Yeah, it could be an optional feature of libdrm, and other components
>>>>> should be able to disable it to remove the overhead.
>>>>
>>>>
>>>> The overhead is negligible, the real problem is the memory footprint.
>>>>
>>>> A brief look at the hash implementation in libdrm showed that this is
>>>> actually really inefficient.
>>>>
>>>> I think we have the choice of implementing a r/b tree to map the CPU
>>>> pointer
>>>> addresses or implement a quadratic tree to map the handles.
>>>>
>>>> The later is easy to do and would also allow to get rid of the hash table
>>>> as
>>>> well.
>>>
>>> We can also use the hash table from mesa/src/util.
>>>
>>> I don't think the overhead would be negligible. It would be a log(n)
>>> insertion in bo_map and a log(n) deletion in bo_unmap. If you did
>>> bo_map+bo_unmap 10000 times, would it be negligible?
>>
>>
>> Compared to what the kernel needs to do for updating the page tables it is
>> less than 1% of the total work.
>>
>> The real question is if it wouldn't be simpler to use a tree for the
>> handles. Since the handles are dense you can just use an unbalanced tree
>> which is really easy.
>>
>> For a tree of the CPU mappings we would need an r/b interval tree, which is
>> hard to implement and quite some overkill.
>>
>> Do you have any numbers how many BOs really get a CPU mapping in a real
>> world application?
>
> Without our suballocator, we sometimes exceeded the max. mmap limit
> (~64K). It should be much less with the suballocator with 128KB slabs,
> probably a few thousands.

Is there a way to verify that it has performance issue if moving the cpu mapping in libdrm hash table
from kernel side?

AFAIW, only one game will use that with close OGL.

Regards,
Jerry

>
> Marek
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-08-02  6:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 10:02 [PATCH 1/2] drm/amdgpu: return bo itself if userptr is cpu addr of bo (v3) Junwei Zhang
     [not found] ` <1532944950-28619-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
2018-07-30 10:02   ` [PATCH 2/2] drm/amdgpu: bump version for API to find bo by cpu mapping Junwei Zhang
2018-07-30 10:47   ` [PATCH 1/2] drm/amdgpu: return bo itself if userptr is cpu addr of bo (v3) Christian König
     [not found]     ` <3d423f44-e47a-e70c-dfd9-80c1ff843e45-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31  1:40       ` Zhou, David(ChunMing)
     [not found]         ` <SN1PR12MB051036BA7AC3560A4FAC68A1B42E0-z7L1TMIYDg5tVDmkcP8tDwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-31  1:49           ` Zhou, David(ChunMing)
     [not found]             ` <SN1PR12MB05106FBFF052EDFD49193ABCB42E0-z7L1TMIYDg5tVDmkcP8tDwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-31  2:32               ` Zhang, Jerry (Junwei)
2018-07-31  6:54           ` Christian König
2018-07-31  6:58       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B6008A1.5050401-5C7GfCeVMHo@public.gmane.org>
2018-07-31  7:03           ` Christian König
     [not found]             ` <c6b11c1f-b32a-4ab8-6a78-aa7886eed60a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31  8:05               ` Zhang, Jerry (Junwei)
     [not found]                 ` <5B601844.3010405-5C7GfCeVMHo@public.gmane.org>
2018-07-31  8:13                   ` Christian König
     [not found]                     ` <5e8f2a76-6cbd-1f80-ec94-fcd79c0fa55c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31  8:58                       ` Zhang, Jerry (Junwei)
     [not found]                         ` <5B60249D.7030503-5C7GfCeVMHo@public.gmane.org>
2018-07-31  9:04                           ` Christian König
     [not found]                             ` <9dc68d5d-561c-242a-b3ba-1c8078ab670f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31  9:54                               ` Zhang, Jerry (Junwei)
     [not found]                                 ` <5B6031CA.4050102-5C7GfCeVMHo@public.gmane.org>
2018-07-31 10:13                                   ` Christian König
     [not found]                                     ` <3ffb8b8c-fae3-92d9-80e1-bd7d0498b4c7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-31 22:07                                       ` Marek Olšák
     [not found]                                         ` <CAAxE2A6uLe_ZMTGQ2dqFbY--Mf15qRrP+tX6pbicokpe8Wo=qQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-01  6:32                                           ` Christian König
     [not found]                                             ` <53eb686a-0747-394a-b0c3-4cd53ab836e2-5C7GfCeVMHo@public.gmane.org>
2018-08-01 17:39                                               ` Marek Olšák
     [not found]                                                 ` <CAAxE2A6C0mmr2vogcAQL+XNQuPU=BqHUGjqAMVnS3pK37XJa0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-01 17:52                                                   ` Christian König
     [not found]                                                     ` <edbcf817-75ea-6e6a-d64a-6274a78308e7-5C7GfCeVMHo@public.gmane.org>
2018-08-01 17:59                                                       ` Marek Olšák
     [not found]                                                         ` <CAAxE2A4=k5_20jaPcM9awxQ69MhXY2wtEX9NFxZU9=43_SsRug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-01 18:29                                                           ` Christian König
     [not found]                                                             ` <ba1798f5-9aa9-6d55-791a-b2fd52087ea7-5C7GfCeVMHo@public.gmane.org>
2018-08-02  0:00                                                               ` Marek Olšák
     [not found]                                                                 ` <CAAxE2A4bma0u8R+ggETPoUycC=MTkrs0oUGJFW8kGx__Sf35eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-02  6:20                                                                   ` Zhang, Jerry (Junwei) [this message]
     [not found]                                                                     ` <5B62A2A0.5060508-5C7GfCeVMHo@public.gmane.org>
2018-08-02  6:29                                                                       ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B62A2A0.5060508@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=maraeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.