From: Kenny Ho <Kenny.Ho@amd.com>
To: <y2kenny@gmail.com>, <cgroups@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>,
<amd-gfx@lists.freedesktop.org>, <tj@kernel.org>,
<alexander.deucher@amd.com>, <christian.koenig@amd.com>,
<felix.kuehling@amd.com>, <joseph.greathouse@amd.com>,
<jsparks@cray.com>, <lkaplan@cray.com>, <daniel@ffwll.ch>,
<nirmoy.das@amd.com>, <damon.mcdougall@amd.com>,
<juan.zuniga-anaya@amd.com>
Cc: Kenny Ho <Kenny.Ho@amd.com>
Subject: [PATCH 06/11] drm, cgroup: Add GEM buffer allocation count stats
Date: Fri, 14 Feb 2020 10:56:45 -0500 [thread overview]
Message-ID: <20200214155650.21203-7-Kenny.Ho@amd.com> (raw)
In-Reply-To: <20200214155650.21203-1-Kenny.Ho@amd.com>
drm.buffer.count.stats
A read-only flat-keyed file which exists on all cgroups. Each
entry is keyed by the drm device's major:minor.
Total number of GEM buffer allocated.
Change-Id: Iad29bdf44390dbcee07b1e72ea0ff811aa3b9dcd
Signed-off-by: Kenny Ho <Kenny.Ho@amd.com>
---
Documentation/admin-guide/cgroup-v2.rst | 6 ++++++
include/linux/cgroup_drm.h | 3 +++
kernel/cgroup/drm.c | 22 +++++++++++++++++++---
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 75b97962b127..19fcf54ace83 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2075,6 +2075,12 @@ DRM Interface Files
Largest (high water mark) GEM buffer allocated in bytes.
+ drm.buffer.count.stats
+ A read-only flat-keyed file which exists on all cgroups. Each
+ entry is keyed by the drm device's major:minor.
+
+ Total number of GEM buffer allocated.
+
GEM Buffer Ownership
~~~~~~~~~~~~~~~~~~~~
diff --git a/include/linux/cgroup_drm.h b/include/linux/cgroup_drm.h
index 593ad12602cd..51a0cd37da92 100644
--- a/include/linux/cgroup_drm.h
+++ b/include/linux/cgroup_drm.h
@@ -14,6 +14,7 @@
enum drmcg_res_type {
DRMCG_TYPE_BO_TOTAL,
DRMCG_TYPE_BO_PEAK,
+ DRMCG_TYPE_BO_COUNT,
__DRMCG_TYPE_LAST,
};
@@ -27,6 +28,8 @@ struct drmcg_device_resource {
s64 bo_stats_total_allocated;
s64 bo_stats_peak_allocated;
+
+ s64 bo_stats_count_allocated;
};
/**
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index 7a0da70c5a25..bc162aa9971d 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -280,6 +280,9 @@ static void drmcg_print_stats(struct drmcg_device_resource *ddr,
case DRMCG_TYPE_BO_PEAK:
seq_printf(sf, "%lld\n", ddr->bo_stats_peak_allocated);
break;
+ case DRMCG_TYPE_BO_COUNT:
+ seq_printf(sf, "%lld\n", ddr->bo_stats_count_allocated);
+ break;
default:
seq_puts(sf, "\n");
break;
@@ -334,6 +337,12 @@ struct cftype files[] = {
.private = DRMCG_CTF_PRIV(DRMCG_TYPE_BO_PEAK,
DRMCG_FTYPE_STATS),
},
+ {
+ .name = "buffer.count.stats",
+ .seq_show = drmcg_seq_show,
+ .private = DRMCG_CTF_PRIV(DRMCG_TYPE_BO_COUNT,
+ DRMCG_FTYPE_STATS),
+ },
{ } /* terminate */
};
@@ -385,6 +394,8 @@ void drmcg_chg_bo_alloc(struct drmcg *drmcg, struct drm_device *dev,
if (ddr->bo_stats_peak_allocated < (s64)size)
ddr->bo_stats_peak_allocated = (s64)size;
+
+ ddr->bo_stats_count_allocated++;
}
mutex_unlock(&dev->drmcg_mutex);
}
@@ -402,15 +413,20 @@ EXPORT_SYMBOL(drmcg_chg_bo_alloc);
void drmcg_unchg_bo_alloc(struct drmcg *drmcg, struct drm_device *dev,
size_t size)
{
+ struct drmcg_device_resource *ddr;
int devIdx = dev->primary->index;
if (drmcg == NULL)
return;
mutex_lock(&dev->drmcg_mutex);
- for ( ; drmcg != NULL; drmcg = drmcg_parent(drmcg))
- drmcg->dev_resources[devIdx]->bo_stats_total_allocated
- -= (s64)size;
+ for ( ; drmcg != NULL; drmcg = drmcg_parent(drmcg)) {
+ ddr = drmcg->dev_resources[devIdx];
+
+ ddr->bo_stats_total_allocated -= (s64)size;
+
+ ddr->bo_stats_count_allocated--;
+ }
mutex_unlock(&dev->drmcg_mutex);
}
EXPORT_SYMBOL(drmcg_unchg_bo_alloc);
--
2.25.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-02-14 15:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 15:56 [PATCH 00/11] new cgroup controller for gpu/drm subsystem Kenny Ho
2020-02-14 15:56 ` [PATCH 01/11] cgroup: Introduce cgroup for drm subsystem Kenny Ho
2020-02-14 15:56 ` [PATCH 02/11] drm, cgroup: Bind drm and cgroup subsystem Kenny Ho
2020-02-14 15:56 ` [PATCH 03/11] drm, cgroup: Initialize drmcg properties Kenny Ho
2020-02-14 15:56 ` [PATCH 04/11] drm, cgroup: Add total GEM buffer allocation stats Kenny Ho
2020-02-14 15:56 ` [PATCH 05/11] drm, cgroup: Add peak " Kenny Ho
2020-02-14 15:56 ` Kenny Ho [this message]
2020-02-14 15:56 ` [PATCH 07/11] drm, cgroup: Add total GEM buffer allocation limit Kenny Ho
2020-02-14 15:56 ` [PATCH 08/11] drm, cgroup: Add peak " Kenny Ho
2020-02-14 15:56 ` [PATCH 09/11] drm, cgroup: Introduce lgpu as DRM cgroup resource Kenny Ho
2020-02-14 16:44 ` Jason Ekstrand
2020-02-14 16:59 ` Jason Ekstrand
2020-02-14 17:08 ` Kenny Ho
2020-02-14 17:48 ` Jason Ekstrand
2020-02-14 18:34 ` Daniel Vetter
2020-02-14 18:51 ` Kenny Ho
2020-02-14 19:17 ` Tejun Heo
2020-02-14 20:28 ` Kenny Ho
2020-02-14 21:15 ` Tejun Heo
2020-02-19 16:21 ` Johannes Weiner
2020-02-19 16:18 ` Johannes Weiner
2020-02-19 16:28 ` Kenny Ho
2020-02-19 18:38 ` Johannes Weiner
2020-02-21 5:59 ` Kenny Ho
2020-02-14 15:56 ` [PATCH 10/11] drm, cgroup: add update trigger after limit change Kenny Ho
2020-02-14 15:56 ` [PATCH 11/11] drm/amdgpu: Integrate with DRM cgroup Kenny Ho
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=20200214155650.21203-7-Kenny.Ho@amd.com \
--to=kenny.ho@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=cgroups@vger.kernel.org \
--cc=christian.koenig@amd.com \
--cc=damon.mcdougall@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--cc=joseph.greathouse@amd.com \
--cc=jsparks@cray.com \
--cc=juan.zuniga-anaya@amd.com \
--cc=lkaplan@cray.com \
--cc=nirmoy.das@amd.com \
--cc=tj@kernel.org \
--cc=y2kenny@gmail.com \
/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).