dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: Thomas Hellstrom
	<thellstrom-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>,
	"dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	"Koenig,
	Christian" <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	"thomas-4+hqylr40dJg9hUCZPvPmw@public.gmane.org"
	<thomas-4+hqylr40dJg9hUCZPvPmw@public.gmane.org>
Subject: Re: [PATCH 1/1] [RFC] drm/ttm: Don't init dma32_zone on 64-bit systems
Date: Tue, 19 Feb 2019 17:06:42 +0000	[thread overview]
Message-ID: <2be5739a-fe9a-f436-48a2-fb420cb97a13@amd.com> (raw)
In-Reply-To: <eaad8f2dc24e98c68036801ccd6a871586033d31.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>

On 2019-02-18 3:39 p.m., Thomas Hellstrom wrote:
> On Mon, 2019-02-18 at 18:07 +0100, Christian König wrote:
>> Am 18.02.19 um 10:47 schrieb Thomas Hellstrom:
>>> On Mon, 2019-02-18 at 09:20 +0000, Koenig, Christian wrote:
>>>> Another good question is also why the heck the acc_size counts
>>>> towards
>>>> the DMA32 zone?
>>> DMA32 TTM pages are accounted in the DMA32 zone. Other pages are
>>> not.
>> Yeah, I'm perfectly aware of this. But this is for the accounting
>> size!
>>
>> We have an accounting for the stuff needed additional to the pages
>> backing the BO (e.g. the page and DMA addr array).
>>
>> And from the bug description it sounds like we use the DMA32 zone
>> for
>> this accounting which of course is completely nonsense.
> It's actually accounted in all available zones, since it would be
> pretty hard to determine exactly where that memory should be accounted.
> In particular if it's vmalloced. It might be DMA32, it might not. Given
> the objective of stopping malicious user-space from exhausting the
> DMA32 zone it was, at the time the code was written, a reasonable
> approximation. With ever increasing memory sizes, there might be better
> solutions?

As far as I can see, in TTM, ttm_mem_global_alloc is only used for the 
acc_size in ttm_bo_init_reserved. Other than that vmwgfx also seems to 
use it to account for a few things that are allocated with kmalloc.

So would a better solution be to change ttm_mem_global_alloc to use only 
the kernel zone?

Regards,
   Felix


>
> /Thomas
>
>> Christian.
>>
>>> For small persistent allocations using ttm_mem_global_alloc(), they
>>> are
>>> accounted also in the DMA32 zone, which may cause over-accounting
>>> of
>>> that zone, but that's pretty unlikely to be a big problem..
>>>
>>> /Thomas
>>>
>>>
>>>
>>>
>>>
>>>> In other words why should the internal bookkeeping pages be
>>>> allocated
>>>> in
>>>> the DMA32 zone?
>>>>
>>>> That doesn't sounds valid to me in any way,
>>>> Christian.
>>>>
>>>> Am 18.02.19 um 09:02 schrieb Thomas Hellstrom:
>>>>> Hmm,
>>>>>
>>>>> This zone was intended to stop TTM page allocations from
>>>>> exhausting
>>>>> the DMA32 zone. IIRC dma_alloc_coherent() uses DMA32 by
>>>>> default,
>>>>> which
>>>>> means if we drop this check, other devices may stop functioning
>>>>> unexpectedly?
>>>>>
>>>>> However, in the end I'd expect the kernel page allocation
>>>>> system
>>>>> to
>>>>> make sure there are some pages left in the DMA32 zone,
>>>>> otherwise
>>>>> random non-IO page allocations would also potentially exhaust
>>>>> the
>>>>> DMA32 zone without anybody caring, which means removing this
>>>>> zone
>>>>> wouldn't be any worse than whatever other subsystems may be
>>>>> doing
>>>>> already...
>>>>>
>>>>> /Thomas
>>>>>
>>>>>
>>>>> On 2/16/19 12:02 AM, Kuehling, Felix wrote:
>>>>>> This is an RFC. I'm not sure this is the right solution, but
>>>>>> it
>>>>>> highlights the problem I'm trying to solve.
>>>>>>
>>>>>> The dma32_zone limits the acc_size of all allocated BOs to
>>>>>> 2GB.
>>>>>> On a
>>>>>> 64-bit system with hundreds of GB of system memory and GPU
>>>>>> memory,
>>>>>> this can become a bottle neck. We're seeing TTM memory
>>>>>> allocation
>>>>>> failures not because we're truly out of memory, but because
>>>>>> we're
>>>>>> out of space in the dma32_zone for the acc_size needed for
>>>>>> our BO
>>>>>> book-keeping.
>>>>>>
>>>>>> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
>>>>>> CC: thellstrom@vmware.com
>>>>>> CC: christian.koenig@amd.com
>>>>>> ---
>>>>>>     drivers/gpu/drm/ttm/ttm_memory.c | 4 ++--
>>>>>>     1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/ttm/ttm_memory.c
>>>>>> b/drivers/gpu/drm/ttm/ttm_memory.c
>>>>>> index f1567c3..bb05365 100644
>>>>>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>>>>>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>>>>>> @@ -363,7 +363,7 @@ static int
>>>>>> ttm_mem_init_highmem_zone(struct
>>>>>> ttm_mem_global *glob,
>>>>>>         glob->zones[glob->num_zones++] = zone;
>>>>>>         return 0;
>>>>>>     }
>>>>>> -#else
>>>>>> +#elifndef CONFIG_64BIT
>>>>>>     static int ttm_mem_init_dma32_zone(struct ttm_mem_global
>>>>>> *glob,
>>>>>>                        const struct sysinfo *si)
>>>>>>     {
>>>>>> @@ -441,7 +441,7 @@ int ttm_mem_global_init(struct
>>>>>> ttm_mem_global
>>>>>> *glob)
>>>>>>         ret = ttm_mem_init_highmem_zone(glob, &si);
>>>>>>         if (unlikely(ret != 0))
>>>>>>             goto out_no_zone;
>>>>>> -#else
>>>>>> +#elifndef CONFIG_64BIT
>>>>>>         ret = ttm_mem_init_dma32_zone(glob, &si);
>>>>>>         if (unlikely(ret != 0))
>>>>>>             goto out_no_zone;
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cthellstrom%40vmware.com%7C1a84a2a700cd48b3980a08d695c38ade%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636861064581303965&amp;sdata=6FCAP6YbostgKfEEhRKKh9eQSrfXR%2BfCczYB8WwlPVY%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-02-19 17:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 23:02 [PATCH 1/1] [RFC] drm/ttm: Don't init dma32_zone on 64-bit systems Kuehling, Felix
2019-02-18  8:02 ` Thomas Hellstrom
2019-02-18  9:20   ` Koenig, Christian
2019-02-18  9:47     ` Thomas Hellstrom
     [not found]       ` <d90f7ab569b636db0968c80dad9eb16ce7bf1eab.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-18 17:07         ` Christian König
     [not found]           ` <89c4b66a-152a-d0f3-4ce0-d89f6ef822bb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-02-18 20:39             ` Thomas Hellstrom
     [not found]               ` <eaad8f2dc24e98c68036801ccd6a871586033d31.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-19 17:06                 ` Kuehling, Felix [this message]
     [not found]                   ` <2be5739a-fe9a-f436-48a2-fb420cb97a13-5C7GfCeVMHo@public.gmane.org>
2019-02-20  6:41                     ` Thomas Hellstrom
     [not found]                       ` <19a0abdbd60c251a63975a7ddff31c35a5eb0a31.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-20  8:07                         ` Christian König
2019-02-20  8:14                           ` Thomas Hellstrom
     [not found]                             ` <307f2073-7c15-8dac-58fe-3c0170231530-4+hqylr40dJg9hUCZPvPmw@public.gmane.org>
2019-02-20  8:35                               ` Koenig, Christian
     [not found]                                 ` <66b1fa8a-6449-6fe2-18a0-c7aa2200ac68-5C7GfCeVMHo@public.gmane.org>
2019-02-20  9:01                                   ` Thomas Hellstrom
2019-02-20 19:23                         ` Kuehling, Felix
2019-02-21  6:47                           ` Thomas Hellstrom
2019-02-21  7:59                             ` Koenig, Christian
     [not found]                               ` <4423e7aa-2153-5305-91c2-8d212ae1786b-5C7GfCeVMHo@public.gmane.org>
2019-02-21 16:57                                 ` Kuehling, Felix
     [not found]                                   ` <2a76cb48-10f1-6df2-5b40-8d5b4c52acc4-5C7GfCeVMHo@public.gmane.org>
2019-02-21 17:34                                     ` Thomas Hellstrom
     [not found]                                       ` <39a4a5534ea3d5fa9ba94714e80f919c5a43aea9.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-21 20:24                                         ` Kuehling, Felix
     [not found]                                           ` <2b4ea7ed-08e6-6dd3-7b56-e7c1713fc357-5C7GfCeVMHo@public.gmane.org>
2019-02-21 21:02                                             ` Thomas Hellstrom
     [not found]                                               ` <0f1a3b818a4f6b426dff5c641332a456b08136f8.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-22  7:10                                                 ` Koenig, Christian
2019-02-22 13:45                                                   ` Thomas Hellstrom
     [not found]                                                     ` <0c5e5ad70e2acbf2efd9fd0878768dcd5e008cd3.camel-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2019-02-22 23:06                                                       ` Kuehling, Felix

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=2be5739a-fe9a-f436-48a2-fb420cb97a13@amd.com \
    --to=felix.kuehling-5c7gfcevmho@public.gmane.org \
    --cc=Christian.Koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=thellstrom-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org \
    --cc=thomas-4+hqylr40dJg9hUCZPvPmw@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox