diff mbox series

drm/ttm: stop using GFP_TRANSHUGE_LIGHT

Message ID 20210113131325.223511-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/ttm: stop using GFP_TRANSHUGE_LIGHT | expand

Commit Message

Christian König Jan. 13, 2021, 1:13 p.m. UTC
The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
dma32 and moveable/compound should never be set in the first place.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Daniel Vetter Jan. 13, 2021, 1:27 p.m. UTC | #1
On Wed, Jan 13, 2021 at 02:13:25PM +0100, Christian König wrote:
> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
> dma32 and moveable/compound should never be set in the first place.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Needs Fixes: line and References to the GFP_TRANSHUGE_LIGHT report from
Hans and for the chromium report for the mmap fail. With those:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Also I guess really time for me to stitch together that hack to catch
dma-buf sglist struct page abusers ...
-Daniel

> ---
>  drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 8cd776adc592..11e0313db0ea 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>  	struct page *p;
>  	void *vaddr;
>  
> -	if (order) {
> -		gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
> +	/* Don't set the __GFP_COMP flag for higher order allocations.
> +	 * Mapping pages directly into an userspace process and calling
> +	 * put_page() on a TTM allocated page is illegal.
> +	 */
> +	if (order)
> +		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>  			__GFP_KSWAPD_RECLAIM;
> -		gfp_flags &= ~__GFP_MOVABLE;
> -		gfp_flags &= ~__GFP_COMP;
> -	}
>  
>  	if (!pool->use_dma_alloc) {
>  		p = alloc_pages(gfp_flags, order);
> -- 
> 2.25.1
>
Christian König Jan. 13, 2021, 2:46 p.m. UTC | #2
Am 13.01.21 um 14:27 schrieb Daniel Vetter:
> On Wed, Jan 13, 2021 at 02:13:25PM +0100, Christian König wrote:
>> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
>> dma32 and moveable/compound should never be set in the first place.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
> Needs Fixes: line and References to the GFP_TRANSHUGE_LIGHT report from
> Hans and for the chromium report for the mmap fail.

Which tag should I use for this? Just Link:?

>   With those:
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Also I guess really time for me to stitch together that hack to catch
> dma-buf sglist struct page abusers ...

Oh, yes please.

Christian.

> -Daniel
>
>> ---
>>   drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
>> index 8cd776adc592..11e0313db0ea 100644
>> --- a/drivers/gpu/drm/ttm/ttm_pool.c
>> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
>> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>>   	struct page *p;
>>   	void *vaddr;
>>   
>> -	if (order) {
>> -		gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
>> +	/* Don't set the __GFP_COMP flag for higher order allocations.
>> +	 * Mapping pages directly into an userspace process and calling
>> +	 * put_page() on a TTM allocated page is illegal.
>> +	 */
>> +	if (order)
>> +		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>>   			__GFP_KSWAPD_RECLAIM;
>> -		gfp_flags &= ~__GFP_MOVABLE;
>> -		gfp_flags &= ~__GFP_COMP;
>> -	}
>>   
>>   	if (!pool->use_dma_alloc) {
>>   		p = alloc_pages(gfp_flags, order);
>> -- 
>> 2.25.1
>>
Daniel Vetter Jan. 13, 2021, 3:11 p.m. UTC | #3
On Wed, Jan 13, 2021 at 3:46 PM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 13.01.21 um 14:27 schrieb Daniel Vetter:
> > On Wed, Jan 13, 2021 at 02:13:25PM +0100, Christian König wrote:
> >> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
> >> dma32 and moveable/compound should never be set in the first place.
> >>
> >> Signed-off-by: Christian König <christian.koenig@amd.com>
> > Needs Fixes: line and References to the GFP_TRANSHUGE_LIGHT report from
> > Hans and for the chromium report for the mmap fail.
>
> Which tag should I use for this? Just Link:?

Link: is for the patch submission itself (to link to archives with the
review&discussions), usually it's References is for bug reports and
anything else. I think at least. You can have multiple Link: tags too,
if you record all the previous submissions, that's a bit up to
subsystems and how they all roll.
-Daniel


> >   With those:
> >
> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> >
> > Also I guess really time for me to stitch together that hack to catch
> > dma-buf sglist struct page abusers ...
>
> Oh, yes please.
>
> Christian.
>
> > -Daniel
> >
> >> ---
> >>   drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
> >>   1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> >> index 8cd776adc592..11e0313db0ea 100644
> >> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> >> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> >> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
> >>      struct page *p;
> >>      void *vaddr;
> >>
> >> -    if (order) {
> >> -            gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
> >> +    /* Don't set the __GFP_COMP flag for higher order allocations.
> >> +     * Mapping pages directly into an userspace process and calling
> >> +     * put_page() on a TTM allocated page is illegal.
> >> +     */
> >> +    if (order)
> >> +            gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
> >>                      __GFP_KSWAPD_RECLAIM;
> >> -            gfp_flags &= ~__GFP_MOVABLE;
> >> -            gfp_flags &= ~__GFP_COMP;
> >> -    }
> >>
> >>      if (!pool->use_dma_alloc) {
> >>              p = alloc_pages(gfp_flags, order);
> >> --
> >> 2.25.1
> >>
>
Christian König Jan. 15, 2021, 12:14 p.m. UTC | #4
Hans do you have any more comments or a tested-by?

Otherwise I push it to drm-misc-fixes today.

Thanks,
Christian.

Am 13.01.21 um 14:13 schrieb Christian König:
> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
> dma32 and moveable/compound should never be set in the first place.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 8cd776adc592..11e0313db0ea 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>   	struct page *p;
>   	void *vaddr;
>   
> -	if (order) {
> -		gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
> +	/* Don't set the __GFP_COMP flag for higher order allocations.
> +	 * Mapping pages directly into an userspace process and calling
> +	 * put_page() on a TTM allocated page is illegal.
> +	 */
> +	if (order)
> +		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>   			__GFP_KSWAPD_RECLAIM;
> -		gfp_flags &= ~__GFP_MOVABLE;
> -		gfp_flags &= ~__GFP_COMP;
> -	}
>   
>   	if (!pool->use_dma_alloc) {
>   		p = alloc_pages(gfp_flags, order);
Hans de Goede Jan. 15, 2021, 12:54 p.m. UTC | #5
Hi,

On 1/15/21 1:14 PM, Christian König wrote:
> Hans do you have any more comments or a tested-by?

Sorry, I've been busy chasing after another 5.11 regression,
no comments, also no tested-by, but I do fully expect this to solve
the issue.
 
> Otherwise I push it to drm-misc-fixes today.

That sounds good to me.

Regards,

Hans




> 
> Thanks,
> Christian.
> 
> Am 13.01.21 um 14:13 schrieb Christian König:
>> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
>> dma32 and moveable/compound should never be set in the first place.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
>> index 8cd776adc592..11e0313db0ea 100644
>> --- a/drivers/gpu/drm/ttm/ttm_pool.c
>> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
>> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>>       struct page *p;
>>       void *vaddr;
>>   -    if (order) {
>> -        gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
>> +    /* Don't set the __GFP_COMP flag for higher order allocations.
>> +     * Mapping pages directly into an userspace process and calling
>> +     * put_page() on a TTM allocated page is illegal.
>> +     */
>> +    if (order)
>> +        gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>>               __GFP_KSWAPD_RECLAIM;
>> -        gfp_flags &= ~__GFP_MOVABLE;
>> -        gfp_flags &= ~__GFP_COMP;
>> -    }
>>         if (!pool->use_dma_alloc) {
>>           p = alloc_pages(gfp_flags, order);
>
Christian König Jan. 15, 2021, 1 p.m. UTC | #6
Am 15.01.21 um 13:54 schrieb Hans de Goede:
> Hi,
>
> On 1/15/21 1:14 PM, Christian König wrote:
>> Hans do you have any more comments or a tested-by?
> Sorry, I've been busy chasing after another 5.11 regression,
> no comments, also no tested-by, but I do fully expect this to solve
> the issue.

Yeah, I know what you mean :)

>   
>> Otherwise I push it to drm-misc-fixes today.
> That sounds good to me.

Thanks, going to do so any moment.

Regards,
Christian.

>
> Regards,
>
> Hans
>
>
>
>
>> Thanks,
>> Christian.
>>
>> Am 13.01.21 um 14:13 schrieb Christian König:
>>> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
>>> dma32 and moveable/compound should never be set in the first place.
>>>
>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>> ---
>>>    drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>>>    1 file changed, 6 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
>>> index 8cd776adc592..11e0313db0ea 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_pool.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
>>> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>>>        struct page *p;
>>>        void *vaddr;
>>>    -    if (order) {
>>> -        gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
>>> +    /* Don't set the __GFP_COMP flag for higher order allocations.
>>> +     * Mapping pages directly into an userspace process and calling
>>> +     * put_page() on a TTM allocated page is illegal.
>>> +     */
>>> +    if (order)
>>> +        gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>>>                __GFP_KSWAPD_RECLAIM;
>>> -        gfp_flags &= ~__GFP_MOVABLE;
>>> -        gfp_flags &= ~__GFP_COMP;
>>> -    }
>>>          if (!pool->use_dma_alloc) {
>>>            p = alloc_pages(gfp_flags, order);
Michel Dänzer Jan. 27, 2021, 3:45 p.m. UTC | #7
On 2021-01-13 2:13 p.m., Christian König wrote:
> The only flag we really need is __GFP_NOMEMALLOC, highmem depends on
> dma32 and moveable/compound should never be set in the first place.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_pool.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
> index 8cd776adc592..11e0313db0ea 100644
> --- a/drivers/gpu/drm/ttm/ttm_pool.c
> +++ b/drivers/gpu/drm/ttm/ttm_pool.c
> @@ -79,12 +79,13 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
>   	struct page *p;
>   	void *vaddr;
>   
> -	if (order) {
> -		gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
> +	/* Don't set the __GFP_COMP flag for higher order allocations.
> +	 * Mapping pages directly into an userspace process and calling
> +	 * put_page() on a TTM allocated page is illegal.
> +	 */
> +	if (order)
> +		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
>   			__GFP_KSWAPD_RECLAIM;
> -		gfp_flags &= ~__GFP_MOVABLE;
> -		gfp_flags &= ~__GFP_COMP;
> -	}
>   
>   	if (!pool->use_dma_alloc) {
>   		p = alloc_pages(gfp_flags, order);
> 

I picked up this change today, and got the attached splat while running 
piglit.

scripts/faddr2line drivers/gpu/drm/ttm/ttm.ko ttm_pool_alloc+0x2e4/0x5e0

gives:

ttm_pool_alloc+0x2e4/0x5e0:
  alloc_pages at /home/daenzer/src/linux-git/linux/./include/linux/gfp.h:547

(inlined by) ttm_pool_alloc_page at 
/home/daenzer/src/linux-git/linux/drivers/gpu/drm//ttm/ttm_pool.c:91

(inlined by) ttm_pool_alloc at 
/home/daenzer/src/linux-git/linux/drivers/gpu/drm//ttm/ttm_pool.c:398



I suspect we need __GFP_NOWARN as well to avoid these splats.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 8cd776adc592..11e0313db0ea 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -79,12 +79,13 @@  static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
 	struct page *p;
 	void *vaddr;
 
-	if (order) {
-		gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY |
+	/* Don't set the __GFP_COMP flag for higher order allocations.
+	 * Mapping pages directly into an userspace process and calling
+	 * put_page() on a TTM allocated page is illegal.
+	 */
+	if (order)
+		gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
 			__GFP_KSWAPD_RECLAIM;
-		gfp_flags &= ~__GFP_MOVABLE;
-		gfp_flags &= ~__GFP_COMP;
-	}
 
 	if (!pool->use_dma_alloc) {
 		p = alloc_pages(gfp_flags, order);