Re: [RFC][BUGFIX][PATCH] memcg: fix underflow of mapped_file stat

From: KAMEZAWA Hiroyuki
Date: Tue Apr 13 2010 - 21:44:14 EST


On Wed, 14 Apr 2010 10:03:08 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:

> > > @@ -2563,6 +2565,15 @@ void mem_cgroup_end_migration(struct mem
> > > */
> > > if (ctype == MEM_CGROUP_CHARGE_TYPE_MAPPED)
> > > mem_cgroup_uncharge_page(target);
> > > + else {
> > > + /*
> > > + * When a migrated file cache is remapped, it's not charged.
> > > + * Verify it. Because we're under lock_page(), there are
> > > + * no race with uncharge.
> > > + */
> > > + if (page_mapped(target))
> > > + mem_cgroup_update_file_mapped(mem, target, 1);
> > > + }
> > We cannot rely on page lock, because when we succeeded in page migration,
> > "target" = "newpage" has already unlocked in move_to_new_page(). So the "target"
> > can be removed from the radix-tree theoretically(it's not related to this
> > underflow problem, though).
> > Shouldn't we call lock_page(target) and check "if (!target->mapping)" to handle
> > this case(maybe in another patch) ?
> >
> Sounds reasonable. I think about that.
>

Ah, PageCgroupUsed() is already checked under lock_page_cgroup(). It's enough.

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/