All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v4 10/14] drm/i915/ttm: hide shmem objects from TTM LRU
Date: Wed, 22 Sep 2021 15:59:39 +0200	[thread overview]
Message-ID: <0b568072-7a0d-f41d-6227-4481522a795a@amd.com> (raw)
In-Reply-To: <b42594cb-a9aa-8240-e03b-5d6c303242d0@intel.com>

Am 22.09.21 um 15:34 schrieb Matthew Auld:
> On 21/09/2021 12:48, Christian König wrote:
>> Am 21.09.21 um 13:01 schrieb Matthew Auld:
>>> This is probably a NAK. But ideally we need to somehow prevent TTM from
>>> seeing shmem objects when doing its LRU swap walk. Since these are
>>> EXTERNAL they are ignored anyway, but keeping them in the LRU seems
>>> pretty wasteful.  Trying to use bo_pin() for this is all kinds of nasty
>>> since we need to be able to do the bo_unpin() from the unpopulate hook,
>>> but since that can be called from the BO destroy path we will likely go
>>> down in flames.
>>>
>>> An alternative is to maybe just add EXTERNAL objects to some
>>> bdev->external LRU in TTM, or just don't add them at all?
>>
>> Yeah, that goes into the same direction as why I want to push the LRU 
>> into the resource for some time.
>>
>> The problem is that the LRU is needed for multiple things. E.g. 
>> swapping, GART management, resource constrains, IOMMU teardown etc..
>>
>> So for now I think that everything should be on the LRU even if it 
>> isn't valid to be there for some use case.
>
> Ok. Is it a no-go to keep TT_FLAG_EXTERNAL on say bdev->external?

We could add that as a workaround, but I would rather aim for cleaning 
that up more thoughtfully.

Regards,
Christian.

>
>>
>> Regards,
>> Christian.
>>
>>>
>>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>>> Cc: Christian König <christian.koenig@amd.com>
>>> ---
>>>   drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 17 +++++++++++++++++
>>>   1 file changed, 17 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c 
>>> b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> index 174aebe11264..b438ddb52764 100644
>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> @@ -800,6 +800,22 @@ static unsigned long i915_ttm_io_mem_pfn(struct 
>>> ttm_buffer_object *bo,
>>>       return ((base + sg_dma_address(sg)) >> PAGE_SHIFT) + ofs;
>>>   }
>>> +static void i915_ttm_del_from_lru_notify(struct ttm_buffer_object *bo)
>>> +{
>>> +    struct i915_ttm_tt *i915_tt =
>>> +        container_of(bo->ttm, typeof(*i915_tt), ttm);
>>> +
>>> +    /* Idealy we need to prevent TTM from seeing shmem objects when 
>>> doing
>>> +     * its LRU swap walk. Since these are EXTERNAL they are ignored 
>>> anyway,
>>> +     * but keeping them in the LRU is pretty waseful. Trying to use 
>>> bo_pin()
>>> +     * for this is very nasty since we need to be able to do the 
>>> bo_unpin()
>>> +     * from the unpopulate hook, but since that can be called from 
>>> the BO
>>> +     * destroy path we will go down in flames.
>>> +     */
>>> +    if (bo->ttm && ttm_tt_is_populated(bo->ttm) && i915_tt->is_shmem)
>>> +        list_del_init(&bo->lru);
>>> +}
>>> +
>>>   static struct ttm_device_funcs i915_ttm_bo_driver = {
>>>       .ttm_tt_create = i915_ttm_tt_create,
>>>       .ttm_tt_populate = i915_ttm_tt_populate,
>>> @@ -810,6 +826,7 @@ static struct ttm_device_funcs 
>>> i915_ttm_bo_driver = {
>>>       .move = i915_ttm_move,
>>>       .swap_notify = i915_ttm_swap_notify,
>>>       .delete_mem_notify = i915_ttm_delete_mem_notify,
>>> +    .del_from_lru_notify = i915_ttm_del_from_lru_notify,
>>>       .io_mem_reserve = i915_ttm_io_mem_reserve,
>>>       .io_mem_pfn = i915_ttm_io_mem_pfn,
>>>   };
>>


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [Intel-gfx] [PATCH v4 10/14] drm/i915/ttm: hide shmem objects from TTM LRU
Date: Wed, 22 Sep 2021 15:59:39 +0200	[thread overview]
Message-ID: <0b568072-7a0d-f41d-6227-4481522a795a@amd.com> (raw)
In-Reply-To: <b42594cb-a9aa-8240-e03b-5d6c303242d0@intel.com>

Am 22.09.21 um 15:34 schrieb Matthew Auld:
> On 21/09/2021 12:48, Christian König wrote:
>> Am 21.09.21 um 13:01 schrieb Matthew Auld:
>>> This is probably a NAK. But ideally we need to somehow prevent TTM from
>>> seeing shmem objects when doing its LRU swap walk. Since these are
>>> EXTERNAL they are ignored anyway, but keeping them in the LRU seems
>>> pretty wasteful.  Trying to use bo_pin() for this is all kinds of nasty
>>> since we need to be able to do the bo_unpin() from the unpopulate hook,
>>> but since that can be called from the BO destroy path we will likely go
>>> down in flames.
>>>
>>> An alternative is to maybe just add EXTERNAL objects to some
>>> bdev->external LRU in TTM, or just don't add them at all?
>>
>> Yeah, that goes into the same direction as why I want to push the LRU 
>> into the resource for some time.
>>
>> The problem is that the LRU is needed for multiple things. E.g. 
>> swapping, GART management, resource constrains, IOMMU teardown etc..
>>
>> So for now I think that everything should be on the LRU even if it 
>> isn't valid to be there for some use case.
>
> Ok. Is it a no-go to keep TT_FLAG_EXTERNAL on say bdev->external?

We could add that as a workaround, but I would rather aim for cleaning 
that up more thoughtfully.

Regards,
Christian.

>
>>
>> Regards,
>> Christian.
>>
>>>
>>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>>> Cc: Christian König <christian.koenig@amd.com>
>>> ---
>>>   drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 17 +++++++++++++++++
>>>   1 file changed, 17 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c 
>>> b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> index 174aebe11264..b438ddb52764 100644
>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>>> @@ -800,6 +800,22 @@ static unsigned long i915_ttm_io_mem_pfn(struct 
>>> ttm_buffer_object *bo,
>>>       return ((base + sg_dma_address(sg)) >> PAGE_SHIFT) + ofs;
>>>   }
>>> +static void i915_ttm_del_from_lru_notify(struct ttm_buffer_object *bo)
>>> +{
>>> +    struct i915_ttm_tt *i915_tt =
>>> +        container_of(bo->ttm, typeof(*i915_tt), ttm);
>>> +
>>> +    /* Idealy we need to prevent TTM from seeing shmem objects when 
>>> doing
>>> +     * its LRU swap walk. Since these are EXTERNAL they are ignored 
>>> anyway,
>>> +     * but keeping them in the LRU is pretty waseful. Trying to use 
>>> bo_pin()
>>> +     * for this is very nasty since we need to be able to do the 
>>> bo_unpin()
>>> +     * from the unpopulate hook, but since that can be called from 
>>> the BO
>>> +     * destroy path we will go down in flames.
>>> +     */
>>> +    if (bo->ttm && ttm_tt_is_populated(bo->ttm) && i915_tt->is_shmem)
>>> +        list_del_init(&bo->lru);
>>> +}
>>> +
>>>   static struct ttm_device_funcs i915_ttm_bo_driver = {
>>>       .ttm_tt_create = i915_ttm_tt_create,
>>>       .ttm_tt_populate = i915_ttm_tt_populate,
>>> @@ -810,6 +826,7 @@ static struct ttm_device_funcs 
>>> i915_ttm_bo_driver = {
>>>       .move = i915_ttm_move,
>>>       .swap_notify = i915_ttm_swap_notify,
>>>       .delete_mem_notify = i915_ttm_delete_mem_notify,
>>> +    .del_from_lru_notify = i915_ttm_del_from_lru_notify,
>>>       .io_mem_reserve = i915_ttm_io_mem_reserve,
>>>       .io_mem_pfn = i915_ttm_io_mem_pfn,
>>>   };
>>


  reply	other threads:[~2021-09-22 13:59 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 11:01 [PATCH v4 01/14] drm/ttm: stop calling tt_swapin in vm_access Matthew Auld
2021-09-21 11:01 ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 02/14] drm/ttm: stop setting page->index for the ttm_tt Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 03/14] drm/ttm: move ttm_tt_{add, clear}_mapping into amdgpu Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:29   ` [PATCH v4 03/14] drm/ttm: move ttm_tt_{add,clear}_mapping " Christian König
2021-09-21 11:29     ` [Intel-gfx] [PATCH v4 03/14] drm/ttm: move ttm_tt_{add, clear}_mapping " Christian König
2021-09-21 11:01 ` [PATCH v4 04/14] drm/ttm: remove TTM_PAGE_FLAG_NO_RETRY Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 05/14] drm/ttm: s/FLAG_SG/FLAG_EXTERNAL/ Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:30   ` Christian König
2021-09-21 11:30     ` [Intel-gfx] " Christian König
2021-09-21 11:01 ` [PATCH v4 06/14] drm/ttm: add some kernel-doc for TTM_TT_FLAG_* Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:33   ` Christian König
2021-09-21 11:33     ` [Intel-gfx] " Christian König
2021-09-21 11:01 ` [PATCH v4 07/14] drm/ttm: add TTM_TT_FLAG_EXTERNAL_MAPPABLE Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 08/14] drm/i915/gem: Break out some shmem backend utils Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 09/14] drm/i915/ttm: add tt shmem backend Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-22 12:14   ` Thomas Hellström
2021-09-22 12:14     ` [Intel-gfx] " Thomas Hellström
2021-09-21 11:01 ` [PATCH v4 10/14] drm/i915/ttm: hide shmem objects from TTM LRU Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:48   ` Christian König
2021-09-21 11:48     ` [Intel-gfx] " Christian König
2021-09-22 13:34     ` Matthew Auld
2021-09-22 13:34       ` [Intel-gfx] " Matthew Auld
2021-09-22 13:59       ` Christian König [this message]
2021-09-22 13:59         ` Christian König
2021-09-21 11:01 ` [PATCH v4 11/14] drm/i915/ttm: use cached system pages when evicting lmem Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 12/14] drm/i915: try to simplify make_{un}shrinkable Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 13/14] drm/i915/ttm: make evicted shmem pages visible to the shrinker Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:01 ` [PATCH v4 14/14] drm/i915/ttm: enable shmem tt backend Matthew Auld
2021-09-21 11:01   ` [Intel-gfx] " Matthew Auld
2021-09-21 11:28 ` [PATCH v4 01/14] drm/ttm: stop calling tt_swapin in vm_access Christian König
2021-09-21 11:28   ` [Intel-gfx] " Christian König
2021-09-21 11:37   ` Thomas Hellström
2021-09-21 11:37     ` [Intel-gfx] " Thomas Hellström
2021-09-21 11:42     ` Christian König
2021-09-21 11:42       ` [Intel-gfx] " Christian König
2021-09-21 12:59 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v4,01/14] " Patchwork
2021-09-21 13:01 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-09-21 13:30 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-09-21 16:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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=0b568072-7a0d-f41d-6227-4481522a795a@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=thomas.hellstrom@linux.intel.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.