Skip to contentSkip to conversation

mm/memcg: return -EBUSY when oom-kill-disable modified and memcg use_hierarchy, has children

PATCH In review Wanpeng Li 3 participants 4 messages Jul 5, 2012 – Jul 9, 2012

Subsystems (2)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 mm/memcg: return -EBUSY when oom-kill-disable modified and memcg use_hierarchy, has children

From: Wanpeng Li <[email protected]>

When oom-kill-disable modified by the user and current memcg use_hierarchy, the change can occur, provided the current memcg has no children. If it has children, return -EBUSY is enough.

---
 mm/memcontrol.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
mm/memcontrol.c +5 -2
index 63e36e7..4b64fe0 100644
@@ -4521,11 +4521,14 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
 
 	cgroup_lock();
 	/* oom-kill-disable is a flag for subhierarchy. */
-	if ((parent->use_hierarchy) ||
-	    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {
+	if (parent->use_hierarchy) {
 		cgroup_unlock();
 		return -EINVAL;
+	} else if (memcg->use_hierarchy && !list_empty(&cgrp->children)) {
+		cgroup_unlock();
+		return -EBUSY;
 	}
+
 	memcg->oom_kill_disable = val;
 	if (!val)
 		memcg_oom_recover(memcg);
Signature · 7 lines
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 7 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

When oom-kill-disable modified by the user and current memcg use_hierarchy, the change can occur, provided the current memcg has no children. If it has children, return -EBUSY is enough.

I'm sorry what is the point ? You think -EBUSY should be returned in this case rather than -EINVAl ? Then, why ?

Quoted 16 lines
---
  mm/memcontrol.c |    7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)
mm/memcontrol.c +1 -2
index 63e36e7..4b64fe0 100644
@@ -4521,11 +4521,14 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
 
  	cgroup_lock();
  	/* oom-kill-disable is a flag for subhierarchy. */
-	if ((parent->use_hierarchy) ||
-	    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {
+	if (parent->use_hierarchy) {

mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp, · line 4534

Quoted 10 lines
mm/memcontrol.c +4 -0
  		cgroup_unlock();
  		return -EINVAL;
+	} else if (memcg->use_hierarchy && !list_empty(&cgrp->children)) {
+		cgroup_unlock();
+		return -EBUSY;
  	}
+
  	memcg->oom_kill_disable = val;
  	if (!val)
  		memcg_oom_recover(memcg);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 11 lines · Kamezawa Hiroyuki
Quoted 7 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

When oom-kill-disable modified by the user and current memcg use_hierarchy, the change can occur, provided the current memcg has no children. If it has children, return -EBUSY is enough.

I'm sorry what is the point ? You think -EBUSY should be returned in this case rather than -EINVAl ? Then, why ?

just like in function cmem_cgroup_hierarchy_write:

if((!parent_memcg || !parent_memcg->use_hierarchy) &&

		(val == 1 || val == 0) {
		if (list_empty(&cont->children))
			memcg->use_hierarchy = val;
		else
			return -EBUSY;
} else
		return = -EINVAL;

If memcg->use_hierarchy && has children memcg, the user can try again if children memcg disappear. Or I miss something ....

Regards,
Wanpeng Li

Quoted 12 lines
Quoted 12 lines

---
  mm/memcontrol.c |    7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)
mm/memcontrol.c +0 -0
index 63e36e7..4b64fe0 100644
@@ -4521,11 +4521,14 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
 
Quoted 18 lines
Quoted 6 lines
mm/memcontrol.c +1 -2
  	cgroup_lock();
  	/* oom-kill-disable is a flag for subhierarchy. */
-	if ((parent->use_hierarchy) ||
-	    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {
+	if (parent->use_hierarchy) {

mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp, · line 4534

Quoted 10 lines
mm/memcontrol.c +4 -0
  		cgroup_unlock();
  		return -EINVAL;
+	} else if (memcg->use_hierarchy && !list_empty(&cgrp->children)) {
+		cgroup_unlock();
+		return -EBUSY;
  	}
+
  	memcg->oom_kill_disable = val;
  	if (!val)
  		memcg_oom_recover(memcg);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Wanpeng Li
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

When oom-kill-disable modified by the user and current memcg use_hierarchy, the change can occur, provided the current memcg has no children. If it has children, return -EBUSY is enough.

I do not think EBUSY makes any difference. I would much rather see the test go away...

Quoted 29 lines
---
 mm/memcontrol.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
mm/memcontrol.c +5 -2
index 63e36e7..4b64fe0 100644
@@ -4521,11 +4521,14 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
 
 	cgroup_lock();
 	/* oom-kill-disable is a flag for subhierarchy. */
-	if ((parent->use_hierarchy) ||
-	    (memcg->use_hierarchy && !list_empty(&cgrp->children))) {
+	if (parent->use_hierarchy) {
 		cgroup_unlock();
 		return -EINVAL;
+	} else if (memcg->use_hierarchy && !list_empty(&cgrp->children)) {
+		cgroup_unlock();
+		return -EBUSY;
 	}
+
 	memcg->oom_kill_disable = val;
 	if (!val)
 		memcg_oom_recover(memcg);
Signature · 1 line
1.7.5.4
Signature · 12 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>