[Devel] [PATCH RHEL7 COMMIT] cgroup: added rcu node string wrapper for in-cgroup usage.

Vasily Averin vvs at virtuozzo.com
Thu Aug 6 08:31:03 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.el7
------>
commit 11129e0a32053d492e537fc66c485c6156c41c00
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Aug 6 08:31:03 2020 +0300

    cgroup: added rcu node string wrapper for in-cgroup usage.
    
    This will be used in further patches in same patchset.
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
    
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/cgroup.h |  7 +++++++
 kernel/cgroup.c        | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 919cddd..ce46ee8 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -239,6 +239,13 @@ struct cgroup_name {
 	char name[];
 };
 
+struct cgroup_rcu_string {
+	struct rcu_head rcu_head;
+	char val[];
+};
+
+struct cgroup_rcu_string *cgroup_rcu_strdup(const char *str, int len);
+
 struct cgroup {
 	unsigned long flags;		/* "unsigned long" so bitops work */
 
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 956a9ac..f4185de 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -777,6 +777,21 @@ static struct inode *cgroup_new_inode(umode_t mode, struct super_block *sb)
 	return inode;
 }
 
+struct cgroup_rcu_string *cgroup_rcu_strdup(const char *str, int len)
+{
+	struct cgroup_rcu_string *result;
+	size_t buflen = len + 1;
+
+	result = kmalloc(sizeof(*result) + buflen, GFP_KERNEL);
+	if (!result)
+		return ERR_PTR(-ENOMEM);
+	if (strlcpy(result->val, str, buflen) >= buflen) {
+		kfree(result);
+		return ERR_PTR(-ENAMETOOLONG);
+	}
+	return result;
+}
+
 static struct cgroup_name *cgroup_alloc_name(struct dentry *dentry)
 {
 	struct cgroup_name *name;


More information about the Devel mailing list