dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [rfc] drm/ttm/memcg: simplest initial memcg/ttm integration (series v3)
@ 2025-05-12  6:12 Dave Airlie
  2025-05-12  6:12 ` [PATCH 1/7] mm: add gpu active/reclaim per-node stat counters Dave Airlie
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Dave Airlie @ 2025-05-12  6:12 UTC (permalink / raw)
  To: dri-devel, tj, christian.koenig, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Shakeel Butt, Muchun Song
  Cc: cgroups, Waiman Long, simona

Hey,

This is my 3rd attempt to try and integrate ttm and memcg accounting.

I've tried to take on board the feedback given on the last series, and
made some compromises to try and close in on the solution.

Feedback:
1. memcg folks didn't really like the gpu specific stats due to a lack
of global stats being exposed.
2. After consideration of the resource level memcg accounting, I tried
to reason about swap evictions a bit and couldn't come up with a good
way to make it work, so I moved back down to ttm.
3. Use a placement flag instead of ctx flag.

This series starts by adding two per-node stats to the mm layers,
to track memory allocated to the gpu in active use, and memory sitting
in the reclaimable ttm pools.
Then it adds the memcg stat for active gpu as before, 
(reclaimable is not accounted to a memcg at all).
I didn't go back to use __GFP_ACCOUNT and manual stat tweaking, because
kmem is definitely not the correct place to account this memory. This
memory is never used by the kernel, it's used by userspace and the GPU
in nearly all cases, so I think accounting it under kmem is very wrong.
I'm hoping adding the global stats might alleviate any concerns.

I had to move back to ttm_tt accounting instead of ttm_resource, as
when a resource gets evicted to swap, the memory is freed and the memcg
accounting should be updated correctly, as such I ended up going back
to adding the accounting in ttm_tt population paths.

Regards,
Dave.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-05-15  9:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12  6:12 [rfc] drm/ttm/memcg: simplest initial memcg/ttm integration (series v3) Dave Airlie
2025-05-12  6:12 ` [PATCH 1/7] mm: add gpu active/reclaim per-node stat counters Dave Airlie
2025-05-12  6:12 ` [PATCH 2/7] ttm: use gpu mm stats to track gpu memory allocations Dave Airlie
2025-05-12  6:12 ` [PATCH 3/7] memcg: add GPU statistic Dave Airlie
2025-05-12  6:12 ` [PATCH 4/7] memcg: add hooks for gpu memcg charging/uncharging Dave Airlie
2025-05-12  6:12 ` [PATCH 5/7] ttm: add initial memcg integration. (v4) Dave Airlie
2025-05-12 14:42   ` kernel test robot
2025-05-13 13:30   ` Christian König
2025-05-14 11:41   ` [5/7] " Maarten Lankhorst
2025-05-14 11:55     ` Christian König
2025-05-14 17:07       ` Maarten Lankhorst
2025-05-15  8:40         ` Christian König
2025-05-15  9:28           ` Maarten Lankhorst
2025-05-12  6:12 ` [PATCH 6/7] amdgpu: add support for memcg integration Dave Airlie
2025-05-13 13:21   ` Christian König
2025-05-12  6:12 ` [PATCH 7/7] nouveau: add " Dave Airlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).