Skip to contentSkip to conversation

memcg: optimize memcg_get_hierarchical_limit

PATCH Superseded Wanpeng Li 3 participants 7 messages Jun 25, 2012 – Jun 26, 2012

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH v3 3/4 memcg: optimize memcg_get_hierarchical_limit

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 2e81328..4520b57 100644
@@ -3917,9 +3917,9 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 
 	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
 	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
+	cgroup = memcg->css.cgroup;
 
 	while (cgroup->parent) {
 		cgroup = cgroup->parent;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

How did you check that this actually saves some cycles? There are no (compiler) barriers here so it should reordered.

Quoted 23 lines
---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 2e81328..4520b57 100644
@@ -3917,9 +3917,9 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 
 	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
 	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-	cgroup = memcg->css.cgroup;
 	if (!memcg->use_hierarchy)
 		goto out;
+	cgroup = memcg->css.cgroup;
 
 	while (cgroup->parent) {
 		cgroup = cgroup->parent;
Signature · 1 line
1.7.9.5
Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
#2 lore raw
In reply to Wanpeng Li
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

I can't understand the benefit of this patch to the real world...

So, if you wrote the patch description as "clean up" rather than optimize, ok, I'll agree.

Thanks,
-Kame

Quoted 20 lines
---
  mm/memcontrol.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 2e81328..4520b57 100644
@@ -3917,9 +3917,9 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 
  	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
  	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-	cgroup = memcg->css.cgroup;
  	if (!memcg->use_hierarchy)
  		goto out;
+	cgroup = memcg->css.cgroup;
 
  	while (cgroup->parent) {
  		cgroup = cgroup->parent;
author
#3 lore raw
Quoted 11 lines · Kamezawa Hiroyuki
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

I can't understand the benefit of this patch to the real world...

So, if you wrote the patch description as "clean up" rather than optimize, ok, I'll agree.

OK, I will change to "Cleanup". Thank you Kame.

Best Regards,
Wanpeng Li

Quoted 27 lines

Thanks,
-Kame

Quoted 20 lines
---
  mm/memcontrol.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 2e81328..4520b57 100644
@@ -3917,9 +3917,9 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
 
  	min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
  	min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
-	cgroup = memcg->css.cgroup;
  	if (!memcg->use_hierarchy)
  		goto out;
+	cgroup = memcg->css.cgroup;
 
  	while (cgroup->parent) {
  		cgroup = cgroup->parent;
#4 lore raw
Quoted 6 lines · Wanpeng Li
Quoted 5 lines · Kamezawa Hiroyuki
Quoted 4 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

I can't understand the benefit of this patch to the real world...

So, if you wrote the patch description as "clean up" rather than optimize, ok, I'll agree.

OK, I will change to "Cleanup". Thank you Kame.

Does this really clean something up?

Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
author
#5 lore raw
Quoted 9 lines · Michal Hocko
Quoted 8 lines · Wanpeng Li
Quoted 7 lines · Kamezawa Hiroyuki
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

I can't understand the benefit of this patch to the real world...

So, if you wrote the patch description as "clean up" rather than optimize, ok, I'll agree.

OK, I will change to "Cleanup". Thank you Kame.

Does this really clean something up?

OK, just drop it and resend the patch. Hopefully, you can applied! :-)

Best Regards,
Wanpeng Li

Quoted 7 lines
Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
#6 lore raw
In reply to Michal Hocko
Quoted 9 lines · Michal Hocko
Quoted 8 lines · Wanpeng Li
Quoted 7 lines · Kamezawa Hiroyuki
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

I can't understand the benefit of this patch to the real world...

So, if you wrote the patch description as "clean up" rather than optimize, ok, I'll agree.

OK, I will change to "Cleanup". Thank you Kame.

Does this really clean something up?

I just thought unused variable is trash even if it disappears after complie.

Thanks,
-Kame