Skip to contentSkip to conversation

mm/memcg: add BUG() to mem_cgroup_reset

PATCH In review Wanpeng Li 3 participants 5 messages Jul 6, 2012

Subsystems (3)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 mm/memcg: add BUG() to mem_cgroup_reset

From: Wanpeng Li <[email protected]>

Branch in mem_cgroup_reset only can be RES_MAX_USAGE, RES_FAILCNT.

---
 mm/memcontrol.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
mm/memcontrol.c +2 -0
index a501660..5e4d1ab 100644
@@ -3976,6 +3976,8 @@ static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
 		else
 			res_counter_reset_failcnt(&memcg->memsw);
 		break;
+	default:
+		BUG();
 	}
 
 	return 0;
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 14 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Branch in mem_cgroup_reset only can be RES_MAX_USAGE, RES_FAILCNT.

---
mm/memcontrol.c | 2 ++

1 files changed, 2 insertions(+), 0 deletions(-)
mm/memcontrol.c +0 -0
index a501660..5e4d1ab 100644

mm/memcontrol.c static int mem_cgroup_reset(struct cgroup *cont, unsigned int event) · line 3980

Quoted 5 lines
mm/memcontrol.c +2 -0
@@ -3976,6 +3976,8 @@ static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
 		else
 			res_counter_reset_failcnt(&memcg->memsw);
 		break;
+	default:
+		BUG();

It might be not convinced to have "BUG()" here. You might add something for debugging purpose. For example,

	default:
		printk(KERN_WARNING "%s: Unrecognized name %d\n",
			__func__, name);

Thanks,
Gavin

Quoted 12 lines
mm/memcontrol.c +0 -0
 	}
 
 	return 0;
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>

--
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 23 lines · Gavin Shan
Quoted 14 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Branch in mem_cgroup_reset only can be RES_MAX_USAGE, RES_FAILCNT.

---
mm/memcontrol.c | 2 ++

1 files changed, 2 insertions(+), 0 deletions(-)
mm/memcontrol.c +0 -0
index a501660..5e4d1ab 100644

mm/memcontrol.c static int mem_cgroup_reset(struct cgroup *cont, unsigned int event) · line 3980

Quoted 5 lines
mm/memcontrol.c +2 -0
@@ -3976,6 +3976,8 @@ static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
 		else
 			res_counter_reset_failcnt(&memcg->memsw);
 		break;
+	default:
+		BUG();

It might be not convinced to have "BUG()" here. You might add something for debugging purpose. For example,

Quoted 3 lines
	default:
		printk(KERN_WARNING "%s: Unrecognized name %d\n",
			__func__, name);

But many funtions in mm/memcontrol.c use BUG(), if the branch is not present.

Regards,
Wanpeng Li

Quoted 17 lines

Thanks,
Gavin

Quoted 12 lines
mm/memcontrol.c +0 -0
 	}
 
 	return 0;
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>
Quoted 5 lines

--
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>

--
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>

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

From: Wanpeng Li <[email protected]>

Branch in mem_cgroup_reset only can be RES_MAX_USAGE, RES_FAILCNT.

And nobody is passing anything else. Which is easy to prove as this is a private function. And there wouldn't even be any harm passing something else. Please don't add stuff like this.

author
#4 lore raw
Quoted 8 lines · Johannes Weiner
Quoted 3 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Branch in mem_cgroup_reset only can be RES_MAX_USAGE, RES_FAILCNT.

And nobody is passing anything else. Which is easy to prove as this is a private function. And there wouldn't even be any harm passing something else. Please don't add stuff like this.

Ok, thank you for your comment.

I also have another two patches, title:

clarify type in memory cgroups
return -EBUSY when oom-kill-disable modified and memcg use_hierarchy, has children

Hopefully, you can review. Thank you Johannes! :-)

Regards,
Wanpeng Li

--
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>