Re: [PATCH -mm] memcg: fix handling of shmem migration

From: Daisuke Nishimura
Date: Wed Sep 17 2008 - 02:30:38 EST


On Wed, 17 Sep 2008 14:50:03 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> On Wed, 17 Sep 2008 14:46:59 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
>
> > On Wed, 17 Sep 2008 13:31:49 +0900
> > Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> wrote:
> >
> > > PG_swapbacked flag of newpage should be set(if needed) before
> > > mem_cgroup_prepare_migration, because mem_cgroup_charge_common
> > > checks the flag and determines whether it sets PAGE_CGROUP_FLAG_FILE or not.
> > >
> > > Before this patch, if migrating shmem/tmpfs pages, newpage would be
> > > charged with PAGE_CGROUP_FLAG_FILE set, while oldpage has been charged
> > > without the flag.
> > >
> > Nice catch !
> > Thank you.
> >
> > Hmm, should I add MEM_CGROUP_CHARGE_TYPE_SHMEM rather than
> > setting flag to newpage ?
> >
> > Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> >
> I acked but.. can't this change moved into memcontrol.c ?
>

Hmm, something like this?

---
@@ -734,6 +734,9 @@ int mem_cgroup_prepare_migration(struct page *page, struct page *newpa
if (mem_cgroup_subsys.disabled)
return 0;

+ if (PageSwapBacked(page))
+ SetPageSwapBacked(newpage);
+
lock_page_cgroup(page);
pc = page_get_page_cgroup(page);
if (pc) {
---

Or, adding MEM_CGROUP_CHARGE_TYPE_SHMEM and

---
@@ -740,7 +740,10 @@ int mem_cgroup_prepare_migration(struct page *page, struct page *newp
mem = pc->mem_cgroup;
css_get(&mem->css);
if (pc->flags & PAGE_CGROUP_FLAG_CACHE)
- ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
+ if (page_is_file_cache(page))
+ ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
+ else
+ ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM;
}
unlock_page_cgroup(page);
if (mem) {
---
(Of course, mem_cgroup_charge_common should be modified too.)


Thanks,
Daisuke Nishimura.
--
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/