On Tue, 6 May 2025 at 10:37, Shakeel Butt <shakeel.b...@linux.dev> wrote: > > On Fri, May 02, 2025 at 01:35:59PM +1000, Dave Airlie wrote: > > Hey all, > > > > This is my second attempt at adding the initial simple memcg/ttm > > integration. > > > > This varies from the first attempt in two major ways: > > > > 1. Instead of using __GFP_ACCOUNT and direct calling kmem charges > > for pool memory, and directly hitting the GPU statistic, > > Why was the first attempt abandoned? What was the issue with the above > approach?
I had to export a bunch of memcg functionality to drivers (like stat mod and kmem charge interfaces), whereas the new version keeps all of that under a GPU API. > > Waiman > > suggested I just do what the network socket stuff did, which looks > > simpler. So this adds two new memcg apis that wrap accounting. > > The pages no longer get assigned the memcg, it's owned by the > > larger BO object which makes more sense. > > The issue with this approach is that this new stat is only exposed in > memcg. For networking, there are interfaces like /proc/net/sockstat and > /proc/net/protocols which expose system wide network memory usage. I > think we should expose this new "memory used by gpus" at the system > level possibly through /proc/meminfo. We do have some places where we could expose this info via debugfs, but maybe /proc/meminfo should grow this stat, so that it makes sense. > > > > > 2. Christian suggested moving it up a layer to avoid the pool business, > > this was a bit tricky, since I want the gfp flags, but I think it only > > needs some of them and it should work. One other big difference is that > > I aligned it with the dmem interaction, where it tries to get space in > > the memcg before it has even allocated any pages, > > I don't understand the memcg reference in the above statement. Dmem is a > separate cgroup controller orthogonal to memcg. > The TTM code that deals with dmem in the tree is at a level in the TTM code, v1 of this added memcg interactions at a lower level, but Christian suggested, that ttm could interact with both controllers in the same level, and with the new approach it seems right. Dave.