From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, "Tejun Heo" <tj@kernel.org>,
"Zefan Li" <lizefan.x@bytedance.com>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>
Cc: Friedrich Vock <friedrich.vock@gmx.de>,
cgroups@vger.kernel.org, linux-mm@kvack.org
Subject: [RFC PATCH 4/6] drm/xe: Implement cgroup for vram
Date: Thu, 27 Jun 2024 17:47:23 +0200 [thread overview]
Message-ID: <20240627154754.74828-5-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20240627154754.74828-1-maarten.lankhorst@linux.intel.com>
Add vram based cgroup eviction to Xe.
Most hardware with VRAM uses TTM for its management, and can be
similarly trivially enabled.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 4 ++++
drivers/gpu/drm/xe/xe_device_types.h | 4 ++++
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 10 ++++++++++
3 files changed, 18 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 5ef9b50a20d0..6e630d67b13a 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -616,6 +616,10 @@ int xe_device_probe(struct xe_device *xe)
/* Allocate and map stolen after potential VRAM resize */
xe_ttm_stolen_mgr_init(xe);
+ err = drmmcg_register_device(&xe->drm, &xe->cg);
+ if (err)
+ goto err_irq_shutdown;
+
/*
* Now that GT is initialized (TTM in particular),
* we can try to init display, and inherit the initial fb.
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 2e62450d86e1..6b60837d9090 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -7,6 +7,7 @@
#define _XE_DEVICE_TYPES_H_
#include <linux/pci.h>
+#include <linux/cgroup_drm.h>
#include <drm/drm_device.h>
#include <drm/drm_file.h>
@@ -216,6 +217,9 @@ struct xe_device {
/** @devcoredump: device coredump */
struct xe_devcoredump devcoredump;
+ /** @cg: drm cgroup bookkeeping */
+ struct drmcgroup_device cg;
+
/** @info: device info */
struct intel_device_info {
/** @info.graphics_name: graphics IP name */
diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
index fe3779fdba2c..9a625b69fc52 100644
--- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
@@ -339,6 +339,16 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr,
struct ttm_resource_manager *man = &mgr->manager;
int err;
+ if (mem_type != XE_PL_STOLEN) {
+ int cgregion = xe->cg.num_regions++;
+
+ xe->cg.regions[cgregion].size = size;
+ xe->cg.regions[cgregion].name =
+ mem_type == XE_PL_VRAM0 ? "vram0" : "vram1";
+ man->cgdev = &xe->cg;
+ man->cgidx = cgregion;
+ }
+
man->func = &xe_ttm_vram_mgr_func;
mgr->mem_type = mem_type;
mutex_init(&mgr->lock);
--
2.45.2
next prev parent reply other threads:[~2024-06-27 15:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 15:47 [RFC PATCH 0/6] DRM resource management cgroup, try 2 Maarten Lankhorst
2024-06-27 15:47 ` [RFC PATCH 1/6] mm/page_counter: Move calculating protection values to page_counter Maarten Lankhorst
2024-06-27 17:33 ` Roman Gushchin
2024-06-27 18:48 ` Shakeel Butt
2024-06-27 15:47 ` [RFC PATCH 2/6] drm/cgroup: Add memory accounting DRM cgroup Maarten Lankhorst
2024-06-27 17:16 ` Maxime Ripard
2024-06-27 19:22 ` Maarten Lankhorst
2024-06-28 14:04 ` Maxime Ripard
2024-07-01 9:25 ` Maarten Lankhorst
2024-07-01 17:01 ` Tvrtko Ursulin
2024-08-06 13:01 ` Daniel Vetter
2024-08-06 14:09 ` Maxime Ripard
2024-08-06 15:26 ` Daniel Vetter
2024-09-03 8:53 ` Maxime Ripard
2024-09-03 11:26 ` Simona Vetter
2024-08-06 8:19 ` Maxime Ripard
2024-06-27 15:47 ` [RFC PATCH 3/6] drm/ttm: Handle cgroup based eviction in TTM Maarten Lankhorst
2024-06-27 15:47 ` Maarten Lankhorst [this message]
2024-06-27 15:47 ` [RFC PATCH 5/6] drm/amdgpu: Add cgroups implementation Maarten Lankhorst
2024-06-27 15:47 ` [RFC PATCH 6/6] drm/xe: Hack to test with mapped pages instead of vram Maarten Lankhorst
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=20240627154754.74828-5-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=friedrich.vock@gmx.de \
--cc=hannes@cmpxchg.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=lucas.demarchi@intel.com \
--cc=mripard@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tj@kernel.org \
--cc=tzimmermann@suse.de \
/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).