@@ -5,6 +5,7 @@
#include <drm/drm_drv.h>
#include <drm/drm_clients.h>
+#include <linux/cgroup_drm.h>
static DEFINE_XARRAY(drm_pid_clients);
@@ -25,6 +26,7 @@ void drm_clients_close(struct drm_file *file_priv)
{
struct drm_device *dev = file_priv->minor->dev;
struct drm_pid_clients *clients;
+ struct task_struct *task;
lockdep_assert_held(&dev->filelist_mutex);
@@ -35,6 +37,12 @@ void drm_clients_close(struct drm_file *file_priv)
if (WARN_ON_ONCE(!clients))
return;
+ task = get_pid_task(file_priv->cpid, PIDTYPE_PID);
+ if (task) {
+ drmcgroup_client_exited(task);
+ put_task_struct(task);
+ }
+
__del_clients(clients, file_priv);
/*
@@ -13,5 +13,6 @@ struct task_struct;
#define DRM_CGROUP_PRIORITY_MAX (10000)
int drmcgroup_lookup_effective_priority(struct task_struct *task);
+void drmcgroup_client_exited(struct task_struct *task);
#endif /* _CGROUP_DRM_H */
@@ -221,6 +221,14 @@ static void drmcs_attach(struct cgroup_taskset *tset)
css_to_drmcs(css)->effective_priority);
}
+void drmcgroup_client_exited(struct task_struct *task)
+{
+ struct drm_cgroup_state *drmcs = get_task_drmcs(task);
+
+ css_put(&drmcs->css);
+}
+EXPORT_SYMBOL_GPL(drmcgroup_client_exited);
+
static struct drm_cgroup_state root_drmcs = {
.priority = DRM_CGROUP_PRIORITY_DEF,
.effective_priority = DRM_CGROUP_PRIORITY_DEF,