[Devel] [PATCH RHEL8 COMMIT] cgroup/cfs: added 'activate' option to cgroup_add_file

Konstantin Khorenko khorenko at virtuozzo.com
Wed Mar 3 20:22:39 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 4a0b1219c4ca72b0a3b79654b45c7004ba7d7571
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Jan 28 12:04:25 2021 +0300

    cgroup/cfs: added 'activate' option to cgroup_add_file
    
    In kernfs files get created in 'deactivated' state, which means
    they are not visible.
    Add option to activate the file after creation immediately making it visible
    in the parent directory.
    Will be used in later patches.
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index b71d4ccb2f0c..946031fcb393 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -3823,7 +3823,7 @@ static void cgroup_file_notify_timer(struct timer_list *timer)
 }
 
 static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
-			   struct cftype *cft)
+			   struct cftype *cft, bool activate)
 {
 	char name[CGROUP_FILE_NAME_MAX];
 	struct kernfs_node *kn;
@@ -3865,6 +3865,8 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
 		if (IS_ERR(kn_link))
 			return PTR_ERR(kn_link);
 	}
+	if (activate)
+		kernfs_activate(kn);
 
 	return 0;
 }
@@ -3902,7 +3904,7 @@ static int cgroup_addrm_files(struct cgroup_subsys_state *css,
 		if ((cft->flags & CFTYPE_DEBUG) && !cgroup_debug)
 			continue;
 		if (is_add) {
-			ret = cgroup_add_file(css, cgrp, cft);
+			ret = cgroup_add_file(css, cgrp, cft, false);
 			if (ret) {
 				pr_warn("%s: failed to add %s, err=%d\n",
 					__func__, cft->name, ret);


More information about the Devel mailing list