[23/26] cgroup/misc: Add tryget functionality for misc controller

Message ID 20221111183532.3676646-24-kristen@linux.intel.com
State New
Headers
Series Add Cgroup support for SGX EPC memory |

Commit Message

Kristen Carlson Accardi Nov. 11, 2022, 6:35 p.m. UTC
  Allows caller to do a css_tryget() on a specific misc cgroup.

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
---
 include/linux/misc_cgroup.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
  

Patch

diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h
index 7fbf3efb0f62..cee848205715 100644
--- a/include/linux/misc_cgroup.h
+++ b/include/linux/misc_cgroup.h
@@ -112,6 +112,16 @@  static inline void put_misc_cg(struct misc_cg *cg)
 		css_put(&cg->css);
 }
 
+/*
+ * misc_cg_tryget() - Try to increment this misc cgroup ref count.
+ * @cg - cgroup to get.
+ */
+static inline bool misc_cg_tryget(struct misc_cg *cg)
+{
+	if (cg)
+		return css_tryget(&cg->css);
+	return false;
+}
 #else /* !CONFIG_CGROUP_MISC */
 static inline struct misc_cg *root_misc(void)
 {
@@ -175,6 +185,11 @@  static inline void put_misc_cg(struct misc_cg *cg)
 {
 }
 
+static inline bool misc_cg_tryget(struct misc_cg *cg)
+{
+	return true;
+}
+
 static inline int register_misc_cg_notifier(struct notifier_block *nb)
 {
 	return 0;