AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	francois.dugast@intel.com, felix.kuehling@amd.com,
	arunpravin.paneerselvam@amd.com, thomas_os@shipmail.org,
	dakr@redhat.com, luben.tuikov@amd.com,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	matthew.brost@intel.com, boris.brezillon@collabora.com
Subject: Re: [PATCH 06/13] drm/amdgpu: use the new drm_exec object for CS v2
Date: Tue, 20 Jun 2023 13:14:21 +0900	[thread overview]
Message-ID: <7446c685-474d-c69a-2224-e73146987365@gmail.com> (raw)
In-Reply-To: <e163fa54-b016-1879-d1c0-840a4d3885b1@gmail.com>

On 6/20/23 13:07, Tatsuyuki Ishi wrote:
>> @@ -1296,9 +1271,8 @@ static int amdgpu_cs_submit(struct 
>> amdgpu_cs_parser *p,
>>        */
>>       r = 0;
>>       amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
>> -        struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo);
>> -
>> -        r |= !amdgpu_ttm_tt_get_user_pages_done(bo->tbo.ttm, e->range);
>> +        r |= !amdgpu_ttm_tt_get_user_pages_done(e->bo->tbo.ttm,
>> +                            e->range);
>>           e->range = NULL;
> 
> e->range = NULL; needs to be removed, or it's causing *massive* memory 
> leaks.

Actually, I quoted the wrong hunk, the correct one is below.

> @@ -928,18 +874,56 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
>  		e->user_invalidated = userpage_invalidated;
>  	}
>  
> -	r = ttm_eu_reserve_buffers(&p->ticket, &p->validated, true,
> -				   &duplicates);
> -	if (unlikely(r != 0)) {
> -		if (r != -ERESTARTSYS)
> -			DRM_ERROR("ttm_eu_reserve_buffers failed.\n");
> -		goto out_free_user_pages;
> +	drm_exec_while_not_all_locked(&p->exec) {
> +		r = amdgpu_vm_lock_pd(&fpriv->vm, &p->exec);
> +		drm_exec_continue_on_contention(&p->exec);
> +		if (unlikely(r))
> +			goto out_free_user_pages;
> +
> +		amdgpu_bo_list_for_each_entry(e, p->bo_list) {
> +			r = drm_exec_prepare_obj(&p->exec, &e->bo->tbo.base, 2);
> +			drm_exec_break_on_contention(&p->exec);
> +			if (unlikely(r))
> +				goto out_free_user_pages;
> +
> +			e->bo_va = amdgpu_vm_bo_find(vm, e->bo);
> +			e->range = NULL;

This causes the leak.

> +		}
> +		drm_exec_continue_on_contention(&p->exec);
> +
> +		if (p->uf_bo) {
> +			r = drm_exec_prepare_obj(&p->exec, &p->uf_bo->tbo.base,
> +						 2);
> +			drm_exec_continue_on_contention(&p->exec);
> +			if (unlikely(r))
> +				goto out_free_user_pages;
> +		}
>  	}

Tatsuyuki

  reply	other threads:[~2023-06-20  4:14 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04 11:51 Common DRM execution context v4 Christian König
2023-05-04 11:51 ` [PATCH 01/13] drm: execution context for GEM buffers v4 Christian König
2023-05-04 14:02   ` Thomas Hellström (Intel)
2023-05-25 20:42   ` Danilo Krummrich
2023-06-14 12:23   ` Boris Brezillon
2023-06-14 12:30     ` Christian König
2023-06-14 13:02       ` Boris Brezillon
2023-06-17 11:54         ` Boris Brezillon
2023-06-19  8:59           ` Thomas Hellström (Intel)
2023-06-19  9:20             ` Christian König
2023-06-19  9:33               ` Thomas Hellström (Intel)
2023-06-19  9:48                 ` Christian König
2023-06-19 11:06                   ` Thomas Hellström (Intel)
2023-06-21 13:35                     ` Christian König
2023-06-19 10:23               ` Boris Brezillon
2023-06-19 10:12             ` Boris Brezillon
2023-06-19 10:44               ` Christian König
2023-06-19 11:05                 ` Boris Brezillon
2023-06-19 12:01                   ` Boris Brezillon
2023-06-19 12:29                 ` Boris Brezillon
2023-06-20  6:47                   ` Boris Brezillon
2023-06-20  7:28                     ` Christian König
2023-05-04 11:51 ` [PATCH 02/13] drm: add drm_exec selftests v2 Christian König
2023-05-04 12:07   ` Maíra Canal
2023-05-04 12:52     ` Christian König
2023-05-04 11:51 ` [PATCH 03/13] drm/amdkfd: switch over to using drm_exec v2 Christian König
2023-05-04 11:51 ` [PATCH 04/13] drm/amdgpu: use drm_exec for GEM and CSA handling Christian König
2023-05-04 11:51 ` [PATCH 05/13] drm/amdgpu: use drm_exec for MES testing Christian König
2023-05-04 11:51 ` [PATCH 06/13] drm/amdgpu: use the new drm_exec object for CS v2 Christian König
2023-06-12 13:16   ` Tatsuyuki Ishi
2023-06-20  4:07   ` Tatsuyuki Ishi
2023-06-20  4:14     ` Tatsuyuki Ishi [this message]
2023-06-20  8:13       ` Christian König
2023-06-20  8:12     ` Christian König
2023-06-20  8:16       ` Tatsuyuki Ishi
2023-06-20  9:04         ` Tatsuyuki Ishi
2023-06-20  8:28       ` Boris Brezillon
2023-06-20  8:44         ` Christian König
2023-06-20  9:09           ` Boris Brezillon
2023-06-20  9:14             ` Christian König
2023-06-20  9:20               ` Boris Brezillon
2023-05-04 11:51 ` [PATCH 07/13] drm/radeon: switch over to drm_exec Christian König
2023-05-04 11:51 ` [PATCH 08/13] drm/qxl: switch to using drm_exec Christian König
2023-06-20  9:13   ` Thomas Zimmermann
2023-06-20  9:15     ` Christian König
2023-05-04 11:51 ` [PATCH 09/13] drm/lima: " Christian König
2023-05-04 11:51 ` [PATCH 10/13] drm/virtgpu: " Christian König
2023-05-04 11:51 ` [PATCH 11/13] drm/panfrost: " Christian König
2023-05-04 11:51 ` [PATCH 12/13] drm/v3d: " Christian König
2023-05-04 11:51 ` [PATCH 13/13] drm: remove drm_gem_(un)lock_reservations Christian König
  -- strict thread matches above, loose matches on Subject: below --
2023-06-12  9:06 [PATCH 06/13] drm/amdgpu: use the new drm_exec object for CS v2 Tatsuyuki Ishi

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=7446c685-474d-c69a-2224-e73146987365@gmail.com \
    --to=ishitatsuyuki@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=boris.brezillon@collabora.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dakr@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=francois.dugast@intel.com \
    --cc=luben.tuikov@amd.com \
    --cc=matthew.brost@intel.com \
    --cc=thomas_os@shipmail.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