From: Andrew Morton <akpm@linux-foundation.org>
To: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: linux-mm@kvack.org, Michal Hocko <mhocko@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Gavin Shan <shangw@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memcg: wrap mem_cgroup_from_css function
Date: Wed, 18 Jul 2012 14:36:12 -0700 [thread overview]
Message-ID: <20120718143612.e34dd3f3.akpm@linux-foundation.org> (raw)
In-Reply-To: <1342580730-25703-1-git-send-email-liwanp@linux.vnet.ibm.com>
On Wed, 18 Jul 2012 11:05:30 +0800
Wanpeng Li <liwanp@linux.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.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-07-18 21:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a>
2012-07-05 6:28 ` [PATCH] mm/memcg: replace inexistence move_lock_page_cgroup() by move_lock_mem_cgroup() in comment Wanpeng Li
2012-07-09 4:37 ` Kamezawa Hiroyuki
2012-07-11 13:24 ` [PATCH RFC] mm/memcg: calculate max hierarchy limit number instead of min Wanpeng Li
2012-07-11 13:47 ` Michal Hocko
2012-07-12 9:32 ` Wanpeng Li
2012-07-12 10:18 ` Michal Hocko
2012-07-19 6:07 ` Kamezawa Hiroyuki
2012-07-19 6:30 ` Wanpeng Li
2012-07-18 3:05 ` [PATCH] mm/memcg: wrap mem_cgroup_from_css function Wanpeng Li
2012-07-18 21:36 ` Andrew Morton [this message]
2012-07-19 1:31 ` Wanpeng Li
2012-07-19 9:14 ` Kirill A. Shutemov
2012-07-19 9:23 ` Wanpeng Li
2012-07-19 9:29 ` Kirill A. Shutemov
2012-07-19 9:38 ` Gavin Shan
2012-07-19 9:45 ` Kirill A. Shutemov
2012-07-19 10:19 ` Wanpeng Li
2012-07-19 9:38 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120718143612.e34dd3f3.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liwanp@linux.vnet.ibm.com \
--cc=mhocko@suse.cz \
--cc=shangw@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).