All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Olšák" <maraeo@gmail.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: amd-gfx mailing list <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 1/3] drm/amdgpu: add AMDGPU_GEM_CREATE_DISCARDABLE
Date: Tue, 10 May 2022 16:43:44 -0400	[thread overview]
Message-ID: <CAAxE2A7wOfoWWh5VUFmnhyhNeCQ086trJR2BgT+nAmsYZJTbVg@mail.gmail.com> (raw)
In-Reply-To: <CAAxE2A4Bny50ywdTXi0MBV_Pb-onx0yVhPOsb2Lk9XtbJ1R4rQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5170 bytes --]

A better flag name would be:
AMDGPU_GEM_CREATE_BEST_PLACEMENT_OR_DISCARD

Marek

On Tue, May 10, 2022 at 4:13 PM Marek Olšák <maraeo@gmail.com> wrote:

> Does this really guarantee VRAM placement? The code doesn't say anything
> about that.
>
> Marek
>
>
> On Fri, May 6, 2022 at 7:23 AM Christian König <
> ckoenig.leichtzumerken@gmail.com> wrote:
>
>> Add a AMDGPU_GEM_CREATE_DISCARDABLE flag to note that the content of a BO
>> doesn't needs to be preserved during eviction.
>>
>> KFD was already using a similar functionality for SVM BOs so replace the
>> internal flag with the new UAPI.
>>
>> Only compile tested!
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 4 ++--
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 1 +
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 -
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 2 +-
>>  drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 2 +-
>>  include/uapi/drm/amdgpu_drm.h              | 4 ++++
>>  6 files changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>> index 2e16484bf606..bf97d8f07f57 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>> @@ -302,8 +302,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev,
>> void *data,
>>                       AMDGPU_GEM_CREATE_VRAM_CLEARED |
>>                       AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
>>                       AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
>> -                     AMDGPU_GEM_CREATE_ENCRYPTED))
>> -
>> +                     AMDGPU_GEM_CREATE_ENCRYPTED |
>> +                     AMDGPU_GEM_CREATE_DISCARDABLE))
>>                 return -EINVAL;
>>
>>         /* reject invalid gem domains */
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> index 8b7ee1142d9a..1944ef37a61e 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> @@ -567,6 +567,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
>>                 bp->domain;
>>         bo->allowed_domains = bo->preferred_domains;
>>         if (bp->type != ttm_bo_type_kernel &&
>> +           !(bp->flags & AMDGPU_GEM_CREATE_DISCARDABLE) &&
>>             bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
>>                 bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> index 4c9cbdc66995..147b79c10cbb 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> @@ -41,7 +41,6 @@
>>
>>  /* BO flag to indicate a KFD userptr BO */
>>  #define AMDGPU_AMDKFD_CREATE_USERPTR_BO        (1ULL << 63)
>> -#define AMDGPU_AMDKFD_CREATE_SVM_BO    (1ULL << 62)
>>
>>  #define to_amdgpu_bo_user(abo) container_of((abo), struct
>> amdgpu_bo_user, bo)
>>  #define to_amdgpu_bo_vm(abo) container_of((abo), struct amdgpu_bo_vm, bo)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index 41d6f604813d..ba3221a25e75 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -117,7 +117,7 @@ static void amdgpu_evict_flags(struct
>> ttm_buffer_object *bo,
>>         }
>>
>>         abo = ttm_to_amdgpu_bo(bo);
>> -       if (abo->flags & AMDGPU_AMDKFD_CREATE_SVM_BO) {
>> +       if (abo->flags & AMDGPU_GEM_CREATE_DISCARDABLE) {
>>                 placement->num_placement = 0;
>>                 placement->num_busy_placement = 0;
>>                 return;
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> index 5ed8d9b549a4..835b5187f0b8 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
>> @@ -531,7 +531,7 @@ svm_range_vram_node_new(struct amdgpu_device *adev,
>> struct svm_range *prange,
>>         bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
>>         bp.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
>>         bp.flags |= clear ? AMDGPU_GEM_CREATE_VRAM_CLEARED : 0;
>> -       bp.flags |= AMDGPU_AMDKFD_CREATE_SVM_BO;
>> +       bp.flags |= AMDGPU_GEM_CREATE_DISCARDABLE;
>>         bp.type = ttm_bo_type_device;
>>         bp.resv = NULL;
>>
>> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
>> index 9a1d210d135d..57b9d8f0133a 100644
>> --- a/include/uapi/drm/amdgpu_drm.h
>> +++ b/include/uapi/drm/amdgpu_drm.h
>> @@ -140,6 +140,10 @@ extern "C" {
>>   * not require GTT memory accounting
>>   */
>>  #define AMDGPU_GEM_CREATE_PREEMPTIBLE          (1 << 11)
>> +/* Flag that BO can be discarded under memory pressure without keeping
>> the
>> + * content.
>> + */
>> +#define AMDGPU_GEM_CREATE_DISCARDABLE          (1 << 12)
>>
>>  struct drm_amdgpu_gem_create_in  {
>>         /** the requested memory size */
>> --
>> 2.25.1
>>
>>

[-- Attachment #2: Type: text/html, Size: 6288 bytes --]

  reply	other threads:[~2022-05-10 20:44 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 11:23 [PATCH 1/3] drm/amdgpu: add AMDGPU_GEM_CREATE_DISCARDABLE Christian König
2022-05-06 11:23 ` [PATCH 2/3] drm/amdgpu: add AMDGPU_VM_NOALLOC Christian König
2022-05-10 21:21   ` Marek Olšák
2022-05-11  6:06     ` Christian König
2022-05-11  6:15       ` Lazar, Lijo
2022-05-11  7:22         ` Marek Olšák
2022-05-11  7:43           ` Christian König
2022-05-11 18:55             ` Marek Olšák
2022-05-16 11:06               ` Marek Olšák
2022-05-16 11:10                 ` Marek Olšák
2022-05-16 11:53                   ` Christian König
2022-05-16 12:56                     ` Marek Olšák
2022-05-16 16:13                       ` Christian König
2022-05-17  0:12                         ` Marek Olšák
2022-05-17  6:33                           ` Christian König
2022-05-18  8:28                             ` Christian König
2022-05-06 11:23 ` [PATCH 3/3] drm/amdgpu: bump minor version number Christian König
2022-05-06 13:34   ` Alex Deucher
2022-05-12  2:38     ` Marek Olšák
2022-05-06 15:04 ` [PATCH 1/3] drm/amdgpu: add AMDGPU_GEM_CREATE_DISCARDABLE Felix Kuehling
2022-05-10 20:13 ` Marek Olšák
2022-05-10 20:43   ` Marek Olšák [this message]
2022-05-11  6:04     ` Christian König
2022-05-11  7:08       ` Marek Olšák
2022-05-11 21:58         ` Marek Olšák
2022-05-11 22:06           ` Marek Olšák
2022-05-12  7:25             ` Christian König
2022-05-12 22:17               ` Marek Olšák
2022-05-13 11:24                 ` Christian König
     [not found]                 ` <62165c7c-892a-5b35-79dd-b90414ccb5cd@damsy.net>
2022-05-13 11:26                   ` Christian König
2022-07-08 14:58                     ` Marek Olšák
2022-07-11 10:15                       ` 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=CAAxE2A7wOfoWWh5VUFmnhyhNeCQ086trJR2BgT+nAmsYZJTbVg@mail.gmail.com \
    --to=maraeo@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    /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.