Re: [PATCH 0/4] Track exported dma-buffers with memcg

From: Christian König
Date: Thu Jan 12 2023 - 03:19:29 EST


Am 12.01.23 um 09:13 schrieb Shakeel Butt:
On Wed, Jan 11, 2023 at 04:49:36PM -0800, T.J. Mercier wrote:
[...]
The problem is a bit that with gpu allocations reclaim is essentially "we
pass the error to userspace and they get to sort the mess out". There are
some exceptions (some gpu drivers to have shrinkers) would we need to make
sure these shrinkers are tied into the cgroup stuff before we could enable
charging for them?

I'm also not sure that we can depend on the dmabuf being backed at
export time 100% of the time? (They are for dmabuf heaps.) If not,
that'd make calling the existing memcg folio based functions a bit
difficult.

Where does the actual memory get allocated? I see the first patch is
updating the stat in dma_buf_export() and dma_buf_release(). Does the
memory get allocated and freed in those code paths?

Nope, dma_buf_export() just makes the memory available to others.

The driver which calls dma_buf_export() is the one allocating the memory.

Regards,
Christian.