Skip to contentSkip to conversation

mm/memcg: calculate max hierarchy limit number instead of min

RFC PATCH In review Wanpeng Li 4 participants 6 messages Jul 11, 2012 – Jul 19, 2012 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

RFC PATCH 1/1 mm/memcg: calculate max hierarchy limit number instead of min

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

---
 mm/memcontrol.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +7 -7
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		unsigned long long *mem_limit, unsigned long long *memsw_limit)
 {
 	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
 	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		if (!memcg->use_hierarchy)
 			break;
 		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
 		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);
+		max_memsw_limit = max(max_memsw_limit, tmp);
 	}
 out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
 }
 
 static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
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 6 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

No the patch is wrong. The hierarchical limit says when we start reclaiming in the hierarchy and that one is triggered on smallest limit up the way to the hierarchy root.

What are you trying to accomplish here?

Quoted 44 lines
---
 mm/memcontrol.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +7 -7
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		unsigned long long *mem_limit, unsigned long long *memsw_limit)
 {
 	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
 	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		if (!memcg->use_hierarchy)
 			break;
 		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
 		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);
+		max_memsw_limit = max(max_memsw_limit, tmp);
 	}
 out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
 }
 
 static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
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>

A message that is not in the archive (sent off-list or not yet received): 20120711134757.GC4820-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org

author
#3 lore raw
Quoted 11 lines · Michal Hocko
Quoted 6 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

No the patch is wrong. The hierarchical limit says when we start reclaiming in the hierarchy and that one is triggered on smallest limit up the way to the hierarchy root.

I see function mem_cgroup_hierachy_reclaim is removal, and hierarchical reclaim is still work? Could you explain me how it works in details, thank you for your time Michal.

Thanks & Best Regards,
Wanpeng Li

Quoted 55 lines

What are you trying to accomplish here?

Quoted 44 lines
---
 mm/memcontrol.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +7 -7
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		unsigned long long *mem_limit, unsigned long long *memsw_limit)
 {
 	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
 	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		if (!memcg->use_hierarchy)
 			break;
 		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
 		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);
+		max_memsw_limit = max(max_memsw_limit, tmp);
 	}
 out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
 }
 
 static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
Signature · 1 line
1.7.5.4
Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
#4 lore raw
Quoted 9 lines · Wanpeng Li
Quoted 8 lines · Michal Hocko
Quoted 6 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

Quoted 6 lines
Quoted 3 lines

No the patch is wrong. The hierarchical limit says when we start reclaiming in the hierarchy and that one is triggered on smallest limit up the way to the hierarchy root.

I see function mem_cgroup_hierachy_reclaim is removal, and hierarchical reclaim is still work?

I am not aware of that.

Quoted 2 lines

Could you explain me how it works in details, thank you for your time Michal.

I am not sure I understand what you are interested in.

Quoted 58 lines

Thanks & Best Regards,
Wanpeng Li

Quoted 55 lines

What are you trying to accomplish here?

Quoted 44 lines
---
 mm/memcontrol.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +7 -7
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		unsigned long long *mem_limit, unsigned long long *memsw_limit)
 {
 	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
 	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 		if (!memcg->use_hierarchy)
 			break;
 		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
 		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);
+		max_memsw_limit = max(max_memsw_limit, tmp);
 	}
 out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
 }
 
 static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
Signature · 1 line
1.7.5.4
Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
#5 lore raw
In reply to Wanpeng Li
Quoted 8 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

Hm ? What is the hierarchical limit for 'C' in following tree ?

A --- limit=1G
\
B -- limit=500M
\
C - unlimtied

Thanks,
-Kame

Quoted 31 lines
---
  mm/memcontrol.c |   14 +++++++-------
  1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +4 -5
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
  		unsigned long long *mem_limit, unsigned long long *memsw_limit)
  {
  	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
  	cgroup = memcg->css.cgroup;
  	if (!memcg->use_hierarchy)
  		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
  		if (!memcg->use_hierarchy)
  			break;
  		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
  		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);

mm/memcontrol.c static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, · line 3955

Quoted 10 lines
mm/memcontrol.c +3 -2
+		max_memsw_limit = max(max_memsw_limit, tmp);
  	}
  out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
  }
 
  static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 10 lines · Kamezawa Hiroyuki
Quoted 8 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since hierachical_memory_limit shows "of bytes of memory limit with regard to hierarchy under which the memory cgroup is", the count should calculate max hierarchy limit when use_hierarchy in order to show hierarchy subtree limit. hierachical_memsw_limit is the same case.

Quoted 8 lines

Hm ? What is the hierarchical limit for 'C' in following tree ?

A --- limit=1G
\
B -- limit=500M
\
C - unlimtied

Hmm, thank you Kame. :-)

Regards,
Wanpeng Li

Quoted 53 lines

Thanks,
-Kame

Quoted 31 lines
---
  mm/memcontrol.c |   14 +++++++-------
  1 files changed, 7 insertions(+), 7 deletions(-)
mm/memcontrol.c +4 -5
index 69a7d45..6392c0a 100644
@@ -3929,10 +3929,10 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
  		unsigned long long *mem_limit, unsigned long long *memsw_limit)
  {
  	struct cgroup *cgroup;
-	unsigned long long min_limit, min_memsw_limit, tmp;
+	unsigned long long max_limit, max_memsw_limit, tmp;
 
-	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
-	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+	max_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+	max_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
  	cgroup = memcg->css.cgroup;
  	if (!memcg->use_hierarchy)
  		goto out;
@@ -3943,13 +3943,13 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
  		if (!memcg->use_hierarchy)
  			break;
  		tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
-		min_limit = min(min_limit, tmp);
+		max_limit = max(max_limit, tmp);
  		tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-		min_memsw_limit = min(min_memsw_limit, tmp);

mm/memcontrol.c static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, · line 3955

Quoted 10 lines
mm/memcontrol.c +3 -2
+		max_memsw_limit = max(max_memsw_limit, tmp);
  	}
  out:
-	*mem_limit = min_limit;
-	*memsw_limit = min_memsw_limit;
+	*mem_limit = max_limit;
+	*memsw_limit = max_memsw_limit;
  }
 
  static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)

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