[Devel] [PATCH VZ8 v3 05/14] cgroup: exported put_css_set and get_css_set to cgroup.h

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Tue Feb 16 11:44:27 MSK 2021


(Cherry-picked from 8222bbe47ed1e3824e0890a1404735324189c0cb)
Signed-off-by: Valeriy.Vdovin <valeriy.vdovin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/cgroup.h          | 28 ++++++++++++++++++++++++++++
 kernel/cgroup/cgroup-internal.h | 27 ---------------------------
 kernel/cgroup/cgroup.c          |  1 +
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 808b31605d07..391702cf43bd 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -512,6 +512,34 @@ task_get_css(struct task_struct *task, int subsys_id)
 	return css;
 }
 
+void put_css_set_locked(struct css_set *cset);
+
+static inline void put_css_set(struct css_set *cset)
+{
+	unsigned long flags;
+
+	/*
+	 * Ensure that the refcount doesn't hit zero while any readers
+	 * can see it. Similar to atomic_dec_and_lock(), but for an
+	 * rwlock
+	 */
+	if (refcount_dec_not_one(&cset->refcount))
+		return;
+
+	spin_lock_irqsave(&css_set_lock, flags);
+	put_css_set_locked(cset);
+	spin_unlock_irqrestore(&css_set_lock, flags);
+}
+
+/*
+ * refcounted get/put for css_set objects
+ */
+static inline void get_css_set(struct css_set *cset)
+{
+	refcount_inc(&cset->refcount);
+}
+
+
 /**
  * task_css_is_root - test whether a task belongs to the root css
  * @task: the target task
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index ce1c1553c696..829997989c41 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -159,33 +159,6 @@ static inline bool notify_on_release(const struct cgroup *cgrp)
 	return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
 }
 
-void put_css_set_locked(struct css_set *cset);
-
-static inline void put_css_set(struct css_set *cset)
-{
-	unsigned long flags;
-
-	/*
-	 * Ensure that the refcount doesn't hit zero while any readers
-	 * can see it. Similar to atomic_dec_and_lock(), but for an
-	 * rwlock
-	 */
-	if (refcount_dec_not_one(&cset->refcount))
-		return;
-
-	spin_lock_irqsave(&css_set_lock, flags);
-	put_css_set_locked(cset);
-	spin_unlock_irqrestore(&css_set_lock, flags);
-}
-
-/*
- * refcounted get/put for css_set objects
- */
-static inline void get_css_set(struct css_set *cset)
-{
-	refcount_inc(&cset->refcount);
-}
-
 bool cgroup_ssid_enabled(int ssid);
 bool cgroup_on_dfl(const struct cgroup *cgrp);
 bool cgroup_is_thread_root(struct cgroup *cgrp);
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 946031fcb393..de105e651607 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -58,6 +58,7 @@
 #include <linux/psi.h>
 #include <net/sock.h>
 #include <linux/ve.h>
+#include <linux/cgroup.h>
 
 #include <linux/rh_features.h>
 
-- 
2.27.0



More information about the Devel mailing list