[Devel] [PATCH RHEL7 COMMIT] cpuset/mems: don't propagate changes to empty descendant cgroups

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 31 19:13:48 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.vz7.48.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.el7
------>
commit 2b3735690ddee3e5707226a2486166d3e70557c7
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Thu May 31 18:53:54 2018 +0300

    cpuset/mems: don't propagate changes to empty descendant cgroups
    
    1) when setting new cpuset::mems we scan and update descendant cgroups
       as well to avoid children to have wider mems mask.
    
       While doing that we better skip cgroup with empty mems_allowed:
       if current mems_allowed are empty - no tasks are there and userspace
       have to configure cpuset::mems explicitely before attaching tasks to
       this cgroup, so skip further settings propagation.
    
       And don't complain on such not-yet-configured cgroups via WARN_ON,
       that's a normal situation.
    
    2) While scanning descendant cpuset cgroups existing code skips cgroups
       which were ever configured (i.e. mems_allowed is not empty).
    
       This can easily lead to the broken hierarchy when parent and child
       cgroups have non-intersecting mems_allowed. In this case child
       cgroup's effective_mems is not touched, thus tasks in child cgroup
       will run in mem nodes which a not in parent's mems_allowed and
       effective_mems. Weird. Avoid this.
    
       https://bugzilla.redhat.com/show_bug.cgi?id=1584689
    
    https://jira.sw.ru/browse/PSBM-85052
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 kernel/cpuset.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index c3c7859a049c..b7338d4a2eca 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1314,8 +1314,13 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems,
 		if (nodes_empty(*new_mems))
 			*new_mems = parent->effective_mems;
 
-		/* skip the whole subtree if @cp have some CPU */
-		if (!nodes_empty(cp->mems_allowed)) {
+		/*
+		 * If current mems_allowed are empty - no tasks are there and
+		 * userspace have to configure cpuset::mems explicitely before
+		 * attaching tasks to this cgroup, so skip further settings
+		 * propagation.
+		 */
+		if (nodes_empty(cp->mems_allowed)) {
 			pos_cgrp = cgroup_rightmost_descendant(pos_cgrp);
 			continue;
 		}


More information about the Devel mailing list