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: [PATCH 7/7] nouveau: add memcg integration
Date: Mon, 12 May 2025 16:12:13 +1000 [thread overview]
Message-ID: <20250512061913.3522902-8-airlied@gmail.com> (raw)
In-Reply-To: <20250512061913.3522902-1-airlied@gmail.com>
From: Dave Airlie <airlied@redhat.com>
This just adds the memcg init and memcg placement flag support.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/nouveau/nouveau_bo.c | 5 +++--
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 2016c1e7242f..6bd8d9ed9f35 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -450,13 +450,13 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain,
if (domain & NOUVEAU_GEM_DOMAIN_GART) {
pl[*n].mem_type = TTM_PL_TT;
pl[*n].flags = busy & NOUVEAU_GEM_DOMAIN_GART ?
- TTM_PL_FLAG_FALLBACK : 0;
+ TTM_PL_FLAG_FALLBACK : TTM_PL_FLAG_MEMCG;
(*n)++;
}
if (domain & NOUVEAU_GEM_DOMAIN_CPU) {
pl[*n].mem_type = TTM_PL_SYSTEM;
pl[*n].flags = busy & NOUVEAU_GEM_DOMAIN_CPU ?
- TTM_PL_FLAG_FALLBACK : 0;
+ TTM_PL_FLAG_FALLBACK : TTM_PL_FLAG_MEMCG;
(*n)++;
}
@@ -814,6 +814,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
case TTM_PL_VRAM:
nouveau_bo_placement_set(nvbo, NOUVEAU_GEM_DOMAIN_GART,
NOUVEAU_GEM_DOMAIN_CPU);
+ nvbo->placements[0].flags &= ~TTM_PL_FLAG_MEMCG;
break;
default:
nouveau_bo_placement_set(nvbo, NOUVEAU_GEM_DOMAIN_CPU, 0);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 67e3c99de73a..56899c89bdd8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -87,6 +87,7 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
return;
}
+ mem_cgroup_put(nvbo->bo.memcg);
ttm_bo_put(&nvbo->bo);
pm_runtime_mark_last_busy(dev);
@@ -254,6 +255,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,
if (IS_ERR(nvbo))
return PTR_ERR(nvbo);
+ nvbo->bo.memcg = get_mem_cgroup_from_mm(current->mm);
nvbo->bo.base.funcs = &nouveau_gem_object_funcs;
nvbo->no_share = domain & NOUVEAU_GEM_DOMAIN_NO_SHARE;
--
2.49.0
prev parent reply other threads:[~2025-05-12 6:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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
[not found] ` <ea70e6fa-22a1-4adc-927a-5e9c2563f784@lankhorst.se>
2025-05-14 11:55 ` [5/7] " 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 ` Dave Airlie [this message]
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-8-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