[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120719013129.GC4306@kernel>
Date: Thu, 19 Jul 2012 09:31:29 +0800
From: Wanpeng Li <liwanp@...ux.vnet.ibm.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, Michal Hocko <mhocko@...e.cz>,
Johannes Weiner <hannes@...xchg.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Gavin Shan <shangw@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/memcg: wrap mem_cgroup_from_css function
On Wed, Jul 18, 2012 at 02:36:12PM -0700, Andrew Morton wrote:
>On Wed, 18 Jul 2012 11:05:30 +0800
>Wanpeng Li <liwanp@...ux.vnet.ibm.com> wrote:
>
>> wrap mem_cgroup_from_css function to clarify get mem cgroup
>> from cgroup_subsys_state.
>
>This certainly adds clarity.
>
>But it also adds a little more type-safety - these container_of() calls
>can be invoked against *any* struct which has a field called "css".
>With your patch, we add a check that the code is indeed using a
>cgroup_subsys_state*. A small thing, but it's all good.
>
>
>I changed the patch title to the more idiomatic "memcg: add
>mem_cgroup_from_css() helper" and rewrote the changelog to
>
>: Add a mem_cgroup_from_css() helper to replace open-coded invokations of
>: container_of(). To clarify the code and to add a little more type safety.
>
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -396,6 +396,12 @@ static void mem_cgroup_put(struct mem_cgroup *memcg);
>> #include <net/sock.h>
>> #include <net/ip.h>
>>
>> +static inline
>> +struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s)
>> +{
>> + return container_of(s, struct mem_cgroup, css);
>> +}
>
>And with great self-control, I avoided renaming this to
>memcg_from_css(). Sigh. I guess all that extra typing has cardio
>benefits.
Thank you for your time, Andrew. :-)
Thanks & Best Regards,
Wanpeng Li
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists