2012-06-25 08:44:43

by Wanpeng Li

[permalink] [raw]
Subject: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

From: Wanpeng Li <[email protected]>

Optimize memcg_get_hierarchical_limit to save cpu cycle.

Signed-off-by: Wanpeng Li <[email protected]>
---
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2e81328..4520b57 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;
--
1.7.9.5


2012-06-25 09:46:52

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

On Mon 25-06-12 16:44:32, Wanpeng Li wrote:
> 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.

> Signed-off-by: Wanpeng Li <[email protected]>
> ---
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2e81328..4520b57 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
> --
> 1.7.9.5
>

--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic

2012-06-25 09:54:54

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

(2012/06/25 17:44), Wanpeng Li wrote:
> From: Wanpeng Li <[email protected]>
>
> Optimize memcg_get_hierarchical_limit to save cpu cycle.
>
> Signed-off-by: Wanpeng Li <[email protected]>

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

> ---
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2e81328..4520b57 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
>


2012-06-25 10:44:43

by Wanpeng Li

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

On Mon, Jun 25, 2012 at 06:52:25PM +0900, Kamezawa Hiroyuki wrote:
>(2012/06/25 17:44), Wanpeng Li wrote:
>> From: Wanpeng Li <[email protected]>
>>
>> Optimize memcg_get_hierarchical_limit to save cpu cycle.
>>
>> Signed-off-by: Wanpeng Li <[email protected]>
>
>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

>
>Thanks,
>-Kame
>
>> ---
>> mm/memcontrol.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 2e81328..4520b57 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -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;
>>
>
>
>

2012-06-25 11:09:30

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

On Mon 25-06-12 18:43:57, Wanpeng Li wrote:
> On Mon, Jun 25, 2012 at 06:52:25PM +0900, Kamezawa Hiroyuki wrote:
> >(2012/06/25 17:44), Wanpeng Li wrote:
> >> From: Wanpeng Li <[email protected]>
> >>
> >> Optimize memcg_get_hierarchical_limit to save cpu cycle.
> >>
> >> Signed-off-by: Wanpeng Li <[email protected]>
> >
> >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?
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic

2012-06-25 11:19:41

by Wanpeng Li

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

On Mon, Jun 25, 2012 at 01:09:26PM +0200, Michal Hocko wrote:
>On Mon 25-06-12 18:43:57, Wanpeng Li wrote:
>> On Mon, Jun 25, 2012 at 06:52:25PM +0900, Kamezawa Hiroyuki wrote:
>> >(2012/06/25 17:44), Wanpeng Li wrote:
>> >> From: Wanpeng Li <[email protected]>
>> >>
>> >> Optimize memcg_get_hierarchical_limit to save cpu cycle.
>> >>
>> >> Signed-off-by: Wanpeng Li <[email protected]>
>> >
>> >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

>--
>Michal Hocko
>SUSE Labs
>SUSE LINUX s.r.o.
>Lihovarska 1060/12
>190 00 Praha 9
>Czech Republic

2012-06-26 02:47:57

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] memcg: optimize memcg_get_hierarchical_limit

(2012/06/25 20:09), Michal Hocko wrote:
> On Mon 25-06-12 18:43:57, Wanpeng Li wrote:
>> On Mon, Jun 25, 2012 at 06:52:25PM +0900, Kamezawa Hiroyuki wrote:
>>> (2012/06/25 17:44), Wanpeng Li wrote:
>>>> From: Wanpeng Li <[email protected]>
>>>>
>>>> Optimize memcg_get_hierarchical_limit to save cpu cycle.
>>>>
>>>> Signed-off-by: Wanpeng Li <[email protected]>
>>>
>>> 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