From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org, tj@kernel.org,
christian.koenig@amd.com, Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>
Cc: cgroups@vger.kernel.org, Waiman Long <longman@redhat.com>,
simona@ffwll.ch
Subject: [rfc] drm/ttm/memcg: simplest initial memcg/ttm integration (series v3)
Date: Mon, 12 May 2025 16:12:06 +1000 [thread overview]
Message-ID: <20250512061913.3522902-1-airlied@gmail.com> (raw)
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.
next reply other threads:[~2025-05-12 6:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 6:12 Dave Airlie [this message]
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
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=20250512061913.3522902-1-airlied@gmail.com \
--to=airlied@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hannes@cmpxchg.org \
--cc=longman@redhat.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=simona@ffwll.ch \
--cc=tj@kernel.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 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).