All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Matt Roper
	<matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH RFC 7/9] drm: Add helper to obtain cgroup of drm_file's owning process
Date: Fri, 19 Jan 2018 17:51:39 -0800	[thread overview]
Message-ID: <20180120015141.10118-8-matthew.d.roper@intel.com> (raw)
In-Reply-To: <20180120015141.10118-1-matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Matt Roper <matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 include/drm/drm_file.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 0e0c868451a5..08855a99069c 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -32,6 +32,7 @@
 
 #include <linux/types.h>
 #include <linux/completion.h>
+#include <linux/cgroup.h>
 
 #include <uapi/drm/drm.h>
 
@@ -378,4 +379,31 @@ void drm_event_cancel_free(struct drm_device *dev,
 void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
 void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
 
+#ifdef CONFIG_CGROUPS
+/**
+ * drm_file_get_cgroup - obtain cgroup for drm_file's owning process
+ * @file_priv: DRM file
+ * @root: cgroup hierarchy to search for process in
+ *
+ * Obtains the cgroup from a specific hierarchy that the drm_file's owning
+ * process belongs to.  The cgroup may be used to set driver-specific
+ * policy (priority, vram usage, etc.).
+ */
+static inline struct cgroup *
+drm_file_get_cgroup(struct drm_file *file_priv, struct cgroup_root *root)
+{
+	struct task_struct *task = pid_task(file_priv->pid, PIDTYPE_PID);
+	struct cgroup *cgrp;
+
+	mutex_lock(&cgroup_mutex);
+	cgrp = task_cgroup_from_root(task, root);
+	mutex_unlock(&cgroup_mutex);
+
+	return cgrp;
+}
+#else
+static inline struct cgroup *
+drm_file_get_cgroup(struct drm_file *file_priv) { return NULL; }
+#endif
+
 #endif /* _DRM_FILE_H_ */
-- 
2.14.3

  parent reply	other threads:[~2018-01-20  1:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-20  1:51 [PATCH RFC 0/9] DRM management via cgroups Matt Roper
2018-01-20  1:51 ` [PATCH RFC 2/9] cgroup: Add notifier call chain for cgroup destruction Matt Roper
2018-01-20  1:51 ` [PATCH RFC 4/9] cgroup: Export task_cgroup_from_root() and cgroup_mutex for drivers Matt Roper
2018-01-20  1:51 ` [PATCH RFC 5/9] drm: Introduce DRM_IOCTL_CGROUP_SETPARAM Matt Roper
     [not found] ` <20180120015141.10118-1-matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-01-20  1:51   ` [PATCH RFC 1/9] kernfs: Export kernfs_get_inode Matt Roper
2018-01-20  1:51   ` [PATCH RFC 3/9] cgroup: Export cgroup_on_dfl() to drivers Matt Roper
2018-01-20  1:51   ` [PATCH RFC 6/9] drm: Add cgroup helper library Matt Roper
2018-01-22 16:24     ` Tejun Heo
2018-01-20  1:51   ` Matt Roper [this message]
2018-01-20  1:51   ` [PATCH RFC 8/9] drm/i915: Allow default context priority to be set via cgroup parameter Matt Roper
2018-01-20  1:51     ` Matt Roper
     [not found]     ` <20180120015141.10118-9-matthew.d.roper-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-01-20  9:36       ` Chris Wilson
     [not found]         ` <151644097064.13504.16277692057900569412-M6iVdVfohj6unts5RBS2dVaTQe2KTcn/@public.gmane.org>
2018-01-20 10:40           ` Chris Wilson
2018-01-22  9:50             ` Michel Dänzer
2018-01-22  9:56               ` Chris Wilson
2018-01-22 15:57             ` Matt Roper
2018-01-20  1:51   ` [PATCH RFC 9/9] drm/i915: Add context priority to debugfs Matt Roper
2018-01-20  2:20 ` ✗ Fi.CI.BAT: warning for DRM management via cgroups Patchwork
2018-01-22 15:44 ` [PATCH libdrm] tests: Add drm_set_cgrp_param Matt Roper
2018-01-26 17:08   ` Emil Velikov
2018-01-26 17:27     ` [Intel-gfx] " Matt Roper
2018-01-26 17:57       ` Emil Velikov

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=20180120015141.10118-8-matthew.d.roper@intel.com \
    --to=matthew.d.roper-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.