Re: [PATCH 2/5] memcg: use array and ID for quick look up

From: KAMEZAWA Hiroyuki
Date: Tue Aug 24 2010 - 03:47:15 EST


On Tue, 24 Aug 2010 00:44:59 -0700
Greg Thelen <gthelen@xxxxxxxxxx> wrote:

> KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> writes:
>
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> >
> > Now, memory cgroup has an ID per cgroup and make use of it at
> > - hierarchy walk,
> > - swap recording.
> >
> > This patch is for making more use of it. The final purpose is
> > to replace page_cgroup->mem_cgroup's pointer to an unsigned short.
> >
> > This patch caches a pointer of memcg in an array. By this, we
> > don't have to call css_lookup() which requires radix-hash walk.
> > This saves some amount of memory footprint at lookup memcg via id.
> >
> > Changelog: 20100811
> > - adjusted onto mmotm-2010-08-11
> > - fixed RCU related parts.
> > - use attach_id() callback.
> >
> > Changelog: 20100804
> > - fixed description in init/Kconfig
> >
> > Changelog: 20100730
> > - fixed rcu_read_unlock() placement.
> >
> > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> > ---
> > init/Kconfig | 10 ++++++
> > mm/memcontrol.c | 83 ++++++++++++++++++++++++++++++++++++++++++--------------
> > 2 files changed, 73 insertions(+), 20 deletions(-)
> >
> > Index: mmotm-0811/mm/memcontrol.c
> > ===================================================================
> > --- mmotm-0811.orig/mm/memcontrol.c
> > +++ mmotm-0811/mm/memcontrol.c
> > @@ -195,6 +195,7 @@ static void mem_cgroup_oom_notify(struct
> > */
> > struct mem_cgroup {
> > struct cgroup_subsys_state css;
> > + int valid; /* for checking validness under RCU access.*/
> > /*
> > * the counter to account for memory usage
> > */
> > @@ -294,6 +295,29 @@ static bool move_file(void)
> > &mc.to->move_charge_at_immigrate);
> > }
> >
> > +/* 0 is unused */
> > +static atomic_t mem_cgroup_num;
> > +#define NR_MEMCG_GROUPS (CONFIG_MEM_CGROUP_MAX_GROUPS + 1)
> > +static struct mem_cgroup *mem_cgroups[NR_MEMCG_GROUPS] __read_mostly;
> > +
> > +/* Must be called under rcu_read_lock */
> > +static struct mem_cgroup *id_to_memcg(unsigned short id)
> > +{
> > + struct mem_cgroup *ret;
> > + /* see mem_cgroup_free() */
> > + ret = rcu_dereference_check(mem_cgroups[id], rch_read_lock_held());
>
> I think this be rcu_read_lock_held() instead of rch_read_lock_held()?
>
yes, mayb overwritten by following patch.. thank you for finding.


Thanks,
-Kame

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/