On Tue, 28 Feb 2012 22:00:25 +0800 Fengguang Wu <fengguang.wu@xxxxxxxxx> wrote: > From: Greg Thelen <gthelen@xxxxxxxxxx> > > Add calls into memcg dirty page accounting. Notify memcg when pages > transition between clean, file dirty, writeback, and unstable nfs. This > allows the memory controller to maintain an accurate view of the amount > of its memory that is dirty. > > Signed-off-by: Greg Thelen <gthelen@xxxxxxxxxx> > Signed-off-by: Andrea Righi <andrea@xxxxxxxxxxxxxxx> > Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> > Reviewed-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> > Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx> > Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx> > --- > fs/nfs/write.c | 4 ++++ > mm/filemap.c | 1 + > mm/page-writeback.c | 4 ++++ > mm/truncate.c | 1 + > 4 files changed, 10 insertions(+) > > --- linux.orig/fs/nfs/write.c 2012-02-19 10:53:14.000000000 +0800 > +++ linux/fs/nfs/write.c 2012-02-19 10:53:21.000000000 +0800 > @@ -449,6 +449,7 @@ nfs_mark_request_commit(struct nfs_page > nfsi->ncommit++; > spin_unlock(&inode->i_lock); > pnfs_mark_request_commit(req, lseg); > + mem_cgroup_inc_page_stat(req->wb_page, MEMCG_NR_FILE_UNSTABLE_NFS); Hmm...Is the status UNSTABLE_NFS cannot be obtaiend by 'struct page' ? One idea to avoid adding a new flag to pc->flags is.. Can't we do this by following if 'req' exists per page ? memcg = mem_cgroup_from_page(page); # update memcg's refcnt+1 req->memcg = memcg; # record memcg to req. mem_cgroup_inc_nfs_unstable(memcg) # a new call > inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); > inc_bdi_stat(req->wb_page->mapping->backing_dev_info, BDI_RECLAIMABLE); > __mark_inode_dirty(inode, I_DIRTY_DATASYNC); > @@ -460,6 +461,7 @@ nfs_clear_request_commit(struct nfs_page > struct page *page = req->wb_page; > > if (test_and_clear_bit(PG_CLEAN, &(req)->wb_flags)) { > + mem_cgroup_dec_page_stat(page, MEMCG_NR_FILE_UNSTABLE_NFS); > dec_zone_page_state(page, NR_UNSTABLE_NFS); > dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE); > return 1; > @@ -1408,6 +1410,8 @@ void nfs_retry_commit(struct list_head * > req = nfs_list_entry(page_list->next); > nfs_list_remove_request(req); > nfs_mark_request_commit(req, lseg); > + mem_cgroup_dec_page_stat(req->wb_page, > + MEMCG_NR_FILE_UNSTABLE_NFS); > dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); > dec_bdi_stat(req->wb_page->mapping->backing_dev_info, > BDI_RECLAIMABLE); > --- linux.orig/mm/filemap.c 2012-02-19 10:53:14.000000000 +0800 > +++ linux/mm/filemap.c 2012-02-19 10:53:21.000000000 +0800 > @@ -142,6 +142,7 @@ void __delete_from_page_cache(struct pag > * having removed the page entirely. > */ > if (PageDirty(page) && mapping_cap_account_dirty(mapping)) { > + mem_cgroup_dec_page_stat(page, MEMCG_NR_FILE_DIRTY); I think we can make use of PageDirty() as explained. Thanks, -Kame -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>