[Devel] [PATCH RHEL8 COMMIT] ve/cgroup: Remove rcu_read_lock from cgroup_get_ve_root

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 30 12:32:04 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.23
------>
commit 5b131435b4de2c9f8e479d75ace523c1b68da3f7
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Fri Apr 30 12:32:04 2021 +0300

    ve/cgroup: Remove rcu_read_lock from cgroup_get_ve_root
    
    It is likely a leftover from __cgroup_path where it protects cgrp->name
    in cgroup_get_ve_root there is nothing rcu_dereferenced, also in
    cgroup_is_descendant there is no rcu for cgrp->parent.
    
    https://jira.sw.ru/browse/PSBM-69678
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    eshatokhin@:
    It seems, the actual fix for PSBM-69678  was ported to VZ8 as a part of
      90c47968843b3 "ve/cgroups: Introduce subgroups_limit control"
    and
      90368f957e01b "ve/sched/stat: Introduce functions to calculate vcpustat data".
    
    Only "f8168436b4eb ve/cgroup: remove rcu_read_lock from cgroup_get_ve_root"
    was skipped, so here it is.
    
    cgroup_get_ve_root1() does not dereference RCU-protected pointers,
    cgroup_parent() does not do that do that either, so rcu_read_lock/unlock
    are not needed.
    
    Fixes: 90c47968843b ("ve/cgroups: Introduce subgroups_limit control")
    Done in the scope of https://jira.sw.ru/browse/PSBM-127794.
    
    Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 4bd2401fb411..96f7f0b1e913 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2114,7 +2114,6 @@ struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp)
 {
 	struct cgroup *ve_root = NULL;
 
-	rcu_read_lock();
 	do {
 		if (test_bit(CGRP_VE_ROOT, &cgrp->flags)) {
 			ve_root = cgrp;
@@ -2122,7 +2121,6 @@ struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp)
 		}
 		cgrp = cgroup_parent(cgrp);
 	} while (cgrp);
-	rcu_read_unlock();
 
 	return ve_root;
 }


More information about the Devel mailing list