@@ -867,6 +867,7 @@ int cgroup_priv_getkey(void (*free)(struct kref *));
void cgroup_priv_destroykey(int key);
int cgroup_priv_install(struct cgroup *cgrp, int key, struct kref *ref);
struct kref *cgroup_priv_get(struct cgroup *cgrp, int key);
+struct kref *cgroup_priv_get_current(int key);
void cgroup_priv_release(struct cgroup *cgrp, int key);
#endif /* _LINUX_CGROUP_H */
@@ -6079,6 +6079,29 @@ cgroup_priv_get(struct cgroup *cgrp, int key)
}
EXPORT_SYMBOL_GPL(cgroup_priv_get);
+/**
+ * cgroup_priv_get_current - looks up cgroup private data for current task
+ * @key: key uniquely identifying owner of private data to lookup
+ *
+ * Convenience function that performs cgroup_priv_get() on the cgroup that owns
+ * %current.
+ *
+ * Returns:
+ * A pointer to the private data's kref field, or NULL if no private data has
+ * been registered.
+ */
+struct kref *
+cgroup_priv_get_current(int key)
+{
+ struct cgroup *cgrp = task_get_dfl_cgroup(current);
+ struct kref *ref = cgroup_priv_get(cgrp, key);
+
+ cgroup_put(cgrp);
+
+ return ref;
+}
+EXPORT_SYMBOL_GPL(cgroup_priv_get_current);
+
/**
* cgroup_priv_free - free cgroup private data
* @cgrp: cgroup to release private data for
Getting cgroup private data for the current process' cgroup is such a common pattern that we should add a convenience wrapper for it. Signed-off-by: Matt Roper <matthew.d.roper@intel.com> --- include/linux/cgroup.h | 1 + kernel/cgroup/cgroup.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)