[Devel] [PATCH RHEL8 COMMIT] cgroup: Export put_css_set and get_css_set to cgroup.h
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 3 20:21:11 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.5
------>
commit fb3ea62c3743fe48060be69a68e36c415f1b1cae
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date: Wed Mar 3 20:21:11 2021 +0300
cgroup: Export put_css_set and get_css_set to cgroup.h
Cherry-picked from vz7 commit
8222bbe47ed1 ("cgroup: exported __put_css_set and wrappers to cgroup.h")
Signed-off-by: Valeriy.Vdovin <valeriy.vdovin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
ve/cgroup: Port release_agent virtualization from vz7
This patchset ports virtualization of cgroup release_agent
virtualization from vz7.
Major challanges of porting are differences between vz7 and vz8 cgroup
implementations:
- transition of cgroups to kernfs
- slightly changed locking scheme, which relies on css_set_lock in
places, previously relied on cgroup_mutex.
There is a small number of patches that have been ported without
modifications, but most of the patches had suffered a lot of
modification due to the factors described above.
v1:
- original patchset
v2:
- removed port of CGRP_REMOVED due to the use of CSS_ONLINE in VZ8 for
same reason
- changed ve_set(get)_release_agent_path signature for more optimal
- added ve->is_running check before calling userspace executable
v3:
- use goto after check for ve->is_running in last patch
---
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>
More information about the Devel
mailing list