User: Password:
Subscribe / Log in / New account

[PATCH 0/7 v2] memcg: page_cgroup diet

From:  KAMEZAWA Hiroyuki <>
To:  "" <>
Subject:  [RFC] [PATCH 0/7 v2] memcg: page_cgroup diet
Date:  Fri, 13 Jan 2012 17:30:01 +0900
Message-ID:  <>
Cc:  Ying Han <>, "" <>, "" <>, Michal Hocko <>,, "" <>
Archive-link:  Article

This is just an RFC for dumping my queue to share and get better idea.
Patch order may not be clean. Advice is welcomed.

Now, struct page_cgroup is defined as
struct page_cgroup {
        unsigned long flags;
        struct mem_cgroup *mem_cgroup;

We want to remove ->flags to shrink the size (and integrate into 'struct page').
To do that, we need to remove some flags.

Now, flag is defined as
        PCG_LOCK,  /* Lock for pc->mem_cgroup and following bits. */
        PCG_CACHE, /* charged as cache */
        PCG_USED, /* this object is in use. */
        PCG_MIGRATION, /* under page migration */
        /* flags for mem_cgroup and file and I/O status */
        PCG_MOVE_LOCK, /* For race between move_account v.s. following bits */
        PCG_FILE_MAPPED, /* page is accounted as "mapped" */
We have 6bits now.

This patch series removes PCG_CACHE, PCG_MOVE_LOCK, PCG_FILE_MAPPED.
Then, if we use low 3bits of ->mem_cgroup for PCG_LOCK, PCG_USED, PCG_MIGRATION,
we can remove pc->flags, I guess.

To remove flags, this patch modifes page-stat accounting. After this set, 
per-memcg page stat accounting will be

	mem_cgroup_begin_update_page_stat() --(A)
	modify page status
	mem_cgroup_end_update_page_stat()   --(B)

Between (A) and (B), it's guaranteed the page's pc->mem_cgroup will not be moved.
By this change, move_account() can make use of page's information rather than
page_cgroup's flag and we don't have to duplicate flags in page_cgroup.
I think this is saner and allow us to add more per-memcg vmstat without any
new flags.

I'm now testing but don't see additional overheads.


To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to  For more info on Linux MM,
see: .
Fight unfair telecom internet charges in Canada: sign
Don't email: <a href=mailto:""> </a>

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds