Skip to contentSkip to conversation

memcg: optimize memcg_get_hierarchical_limit

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

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 5/6 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 c821e36..1ca79e2 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
maintainer
#1 lore raw
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

I really would have thought the compiler would detect it, but this patch actually does switch around move and jump.

But this is miniscule and anything but a fastpath...

Quoted 22 lines
---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index c821e36..1ca79e2 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

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

#2 lore raw
In reply to Wanpeng Li
Quoted 15 lines · Wanpeng Li

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 +0 -0
index c821e36..1ca79e2 100644

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

Quoted 10 lines
mm/memcontrol.c +1 -1
@@ -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;

Seriously, this saves nothing.

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