All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Ben Skeggs <bskeggs@redhat.com>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 37/45] drm/ttm: add a helper to allocate a temp tt for copies.
Date: Fri, 25 Sep 2020 15:40:32 +0200	[thread overview]
Message-ID: <94a603bf-7a91-dc6f-9ba9-2561ab8e6f64@amd.com> (raw)
In-Reply-To: <CAKMK7uH+rupecO8uSvK3MzJ8OpDsFMhm0w7e_-9kzdiK-k+Dvg@mail.gmail.com>

Am 25.09.20 um 15:17 schrieb Daniel Vetter:
> [SNIP]
>> Eviction is not a problem because the driver gets asked where to put an
>> evicted BO and then TTM does all the moving.
> Hm I guess then I don't quite get where you see the ping-pong
> happening, I thought that only happens for evicting stuff.

No, eviction is the nice case. One step after another.

E.g. from VRAM to GTT, then from GTT to SYSTEM and then eventually 
swapped out.

> But hey not much actual working experience with ttm over here, I'm just reading
> :-) I thought the issue is that ttm wants to evict from $something to
> SYSTEM, and to do that the driver first needs to set a GTT mapping for
> the SYSTEM ttm_resource allocation, so that it can use the
> blitter/sdma engine or whatever to move the data over. But for
> swap-in/validation I'm confused how you can end up with the "wrong"
> placement, that feels like a driver bug.

The problem happens in the other direction and always directly triggered 
by the driver.

> How exactly can you get into a situation with validation where ttm
> gives you SYSTEM, but not GTT and the driver has to fix that up? I'm
> not really following I think, I guess there's something obvious I'm
> missing.

For example a buffer which was evicted to SYSTEM needs to be moved back 
directly to VRAM.

Or we want to evacuate all buffers from VRAM to SYSTEM because of 
hibernation.

etc....

>>>> Or should we instead move the entire eviction logic out from ttm into
>>>> drivers, building it up from helpers?
>> I've been playing with that thought for a while as well, but then
>> decided against it.
>>
>> The main problem I see is that we sometimes need to evict things from
>> other drivers.
>>
>> E.g. when we overcommitted system memory and move things to swap for
>> example.
> Hm yeah ttm has that limit to avoid stepping into the shrinker,
> directly calling into another driver to keep within the limit while
> ignoring that there's other memory users and caches out there still
> feels wrong, it's kinda a parallel world vs shrinker callbacks. And
> there's nothing stopping you from doing the SYSTEM->SWAP movement from
> a shrinker callback with the locking rules we've established around
> dma_resv (just needs to be a trylock).
>
> So feels a bit backwards if we design ttm eviction around this part of it ...

Ok, that's a good point. Need to think about that a bit more then.

>>>> Then drivers which need gtt for
>>>> moving stuff out of vram can do that right away. Also, this would
>>>> allow us to implement very fancy eviction algorithms like all the
>>>> nonsense we're doing in i915 for gtt handling on gen2/3 (but I really
>>>> hope that never ever becomes a thing again in future gpus, so this is
>>>> maybe more a what-if kind of thing). Not sure how that would look
>>>> like, maybe a special validate function which takes a ttm_resource the
>>>> driver already found (through evicting stuff or whatever) and then ttm
>>>> just does the move and book-keeping and everything. And drivers would
>>>> at first only call validate without allowing any eviction. Ofc anyone
>>>> without special needs could use the standard eviction function that
>>>> validate already has.
>>> Spinning this a bit more, we could have different default eviction
>>> functions with this, e.g. so all the drivers that need gtt mapping for
>>> moving stuff around can share that code, but with specific&flat
>>> control flow instead of lots of ping-ping. And drivers that don't need
>>> gtt mapping (like i915, we just need dma_map_sg which we assume works
>>> always, or something from the ttm dma page pool, which really always
>>> works) can then use something simpler that's completely flat.
>> Ok you need to explain a bit more what exactly the problem with the GTT
>> eviction is here :)
> So the full set of limitations are
> - range limits
> - power-of-two alignement of start
> - some other (smaller) power of two alignment for size (lol)
> - "color", i.e. different caching modes needs at least one page of
> empty space in-between
>
> Stuffing all that into a generic eviction logic is imo silly. On top
> of that we have the eviction collector where we scan the entire thing
> until we've built up a sufficiently big hole, then evict just these
> buffers. If we don't do this then pretty much any big buffer with
> constraints results in the entire GTT getting evicted. Again something
> that's only worth it if you have ridiculous placement constraints like
> these old intel chips. gen2/3 in i915.ko is maybe a bit extreme, but
> having the driver in control of the eviction code feels like a much
> better design than ttm inflicting a one-size-fits-all on everyone. Ofc
> with defaults and building blocks and all that.

Yeah, that makes a lot of sense.

Christian.

> -Daniel
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-09-25 13:40 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24  5:18 [PATCH 00/45] TTM move refactoring Dave Airlie
2020-09-24  5:18 ` [PATCH 01/45] drm/qxl: drop unused code Dave Airlie
2020-09-24 10:23   ` Christian König
2020-09-24  5:18 ` [PATCH 02/45] drm/ttm: handle the SYSTEM->TT path in same place as others Dave Airlie
2020-09-24 10:24   ` Christian König
2020-09-24  5:18 ` [PATCH 03/45] drm/amdgpu/ttm: handle tt moves properly Dave Airlie
2020-09-24 11:10   ` Christian König
2020-09-24  5:18 ` [PATCH 04/45] drm/radeon/ttm: handle ttm " Dave Airlie
2020-09-24 11:10   ` Christian König
2020-09-24  5:18 ` [PATCH 05/45] drm/nouveau/ttm: " Dave Airlie
2020-09-24 11:11   ` Christian König
2020-09-24  5:18 ` [PATCH 06/45] drm/vmwgfx: move null mem checks outside move notifies Dave Airlie
2020-09-24 11:12   ` Christian König
2020-09-24  5:18 ` [PATCH 07/45] drm/vmwgfx: add a move callback Dave Airlie
2020-09-24 11:13   ` Christian König
2020-09-24  5:18 ` [PATCH 08/45] drm/vram_helper: implement a ttm " Dave Airlie
2020-09-24 11:14   ` Christian König
2020-09-24  5:18 ` [PATCH 09/45] drm/ttm: make move callback compulstory Dave Airlie
2020-09-24 11:15   ` Christian König
2020-09-24  5:18 ` [PATCH 10/45] drm/ttm: refactor out common code to setup a new tt backed resource Dave Airlie
2020-09-24 11:17   ` Christian König
2020-09-24  5:18 ` [PATCH 11/45] drm/ttm: split out the move to system from move ttm code Dave Airlie
2020-09-24 11:22   ` Christian König
2020-09-24  5:18 ` [PATCH 12/45] drm/ttm: drop free old node wrapper Dave Airlie
2020-09-24 11:23   ` Christian König
2020-09-24  5:18 ` [PATCH 13/45] drm/ttm: use new move interface for known system->ttm moves Dave Airlie
2020-09-24 11:26   ` Christian König
2020-09-24  5:18 ` [PATCH 14/45] drm/ttm: add move old to system to drivers Dave Airlie
2020-09-24 12:02   ` Christian König
2020-09-24  5:18 ` [PATCH 15/45] drm/ttm: push copy unbind into drivers Dave Airlie
2020-09-24 12:17   ` Christian König
2020-09-24  5:18 ` [PATCH 16/45] drm/radeon/ttm: do move notify actions inside move Dave Airlie
2020-09-24  5:18 ` [PATCH 17/45] drm/amdgpu/ttm: handle invalidation in move callback Dave Airlie
2020-09-24  5:18 ` [PATCH 18/45] drm/nouveau: handle move notify inside " Dave Airlie
2020-09-30  5:53   ` Ben Skeggs
2020-09-24  5:18 ` [PATCH 19/45] drm/qxl/ttm: " Dave Airlie
2020-09-24  5:18 ` [PATCH 20/45] drm/vmwgfx/ttm: handle move notify inside move Dave Airlie
2020-09-24  5:18 ` [PATCH 21/45] drm/vram_helper: call move notify from the move callback Dave Airlie
2020-09-24  5:18 ` [PATCH 22/45] drm/ttm: don't call move notify around move Dave Airlie
2020-09-24  5:18 ` [PATCH 23/45] drm/ttm: move bind out of move_to_new_tt_mem Dave Airlie
2020-09-24  5:18 ` [PATCH 24/45] drm/ttm: handle binding in move callback Dave Airlie
2020-09-24  5:18 ` [PATCH 25/45] drm/ttm: don't call ttm_bo_move_ttm from drivers Dave Airlie
2020-09-24  5:18 ` [PATCH 26/45] drm/ttm: remove bind/unbind callbacks Dave Airlie
2020-09-24 13:32   ` Christian König
2020-09-24  5:18 ` [PATCH 27/45] drm/radeon/ttm: cleanup move exit paths Dave Airlie
2020-09-24  5:18 ` [PATCH 28/45] drm/nouveau/ttm: memcpy waits for bo already Dave Airlie
2020-09-24  5:18 ` [PATCH 29/45] drm/ttm: don't expose move old to system helper to drivers Dave Airlie
2020-09-24  5:18 ` [PATCH 30/45] drm/ttm: add a new invalidate notify callback Dave Airlie
2020-09-24  9:33   ` Daniel Vetter
2020-09-24 12:25   ` Christian König
2020-09-29  3:23     ` Dave Airlie
2020-09-29  7:05       ` Christian König
2020-09-24  5:18 ` [PATCH 31/45] drm/radeon: switch to " Dave Airlie
2020-09-24  5:18 ` [PATCH 32/45] drm/amdgpu/ttm: " Dave Airlie
2020-09-24  5:18 ` [PATCH 33/45] drm/nouveau/ttm: " Dave Airlie
2020-09-24  5:18 ` [PATCH 34/45] drm/qxl/ttm: move " Dave Airlie
2020-09-24  5:18 ` [PATCH 35/45] drm/vram-helper: move to invalidate callback Dave Airlie
2020-09-24  7:10   ` Thomas Zimmermann
2020-09-24  5:18 ` [PATCH 36/45] drm/ttm: drop move_notify callback Dave Airlie
2020-09-24  5:18 ` [PATCH 37/45] drm/ttm: add a helper to allocate a temp tt for copies Dave Airlie
2020-09-24 12:42   ` Christian König
2020-09-24 23:14     ` Dave Airlie
2020-09-25  7:39       ` Christian König
2020-09-25  8:16         ` Daniel Vetter
2020-09-25  8:18           ` Daniel Vetter
2020-09-25  9:34             ` Christian König
2020-09-25 13:17               ` Daniel Vetter
2020-09-25 13:40                 ` Christian König [this message]
2020-09-25 13:56                   ` Daniel Vetter
2020-09-24  5:18 ` [PATCH 38/45] drm/nouveau/ttm: use helper to allocate tt temp Dave Airlie
2020-09-24  5:18 ` [PATCH 39/45] drm/radeon/ttm: use new helper to create tmp tt Dave Airlie
2020-09-24  5:18 ` [PATCH 40/45] drm/amdgpu/ttm: use new ttm helper to create temp tt Dave Airlie
2020-09-24  5:18 ` [PATCH 41/45] drm/amdgpu/ttm: use helper function for caching/populate Dave Airlie
2020-09-24  5:18 ` [PATCH 42/45] drm/radeon/ttm: " Dave Airlie
2020-09-24  5:18 ` [PATCH 43/45] drm/nouveau/ttm: use helper for placement + populaate Dave Airlie
2020-09-24  5:18 ` [PATCH 44/45] drm/ttm: move more functionality into helper function Dave Airlie
2020-09-24  5:18 ` [PATCH 45/45] drm/ttm: add a new helper for a cleaning up after a ram move Dave Airlie
2020-09-24  6:40 ` [PATCH 00/45] TTM move refactoring Dave Airlie
2020-09-30  5:51 ` Ben Skeggs

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=94a603bf-7a91-dc6f-9ba9-2561ab8e6f64@amd.com \
    --to=christian.koenig@amd.com \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.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 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.