[PATCH V2] mm: Do not keep page locked during page fault whilecharging it for memcg

From: Michal Hocko
Date: Wed Jun 22 2011 - 08:32:14 EST


On Wed 22-06-11 08:15:16, Christoph Hellwig wrote:
> > +
> > + /* We have to drop the page lock here because memcg
> > + * charging might block for unbound time if memcg oom
> > + * killer is disabled.
> > + */
> > + unlock_page(vmf.page);
> > + ret = mem_cgroup_newpage_charge(page, mm, GFP_KERNEL);
> > + lock_page(vmf.page);
>
> This introduces a completely poinless unlock/lock cycle for non-memcg
> pagefaults. Please make sure it only happens when actually needed.

Fair point. Thanks!
What about the following?
I realize that pushing more memcg logic into mm/memory.c is not nice but
I found it better than pushing the old page into mem_cgroup_newpage_charge.
We could also check whether the old page is in the root cgroup because
memcg oom killer is not active there but that would add more code into
this hot path so I guess it is not worth it.

Changes since v1
- do not unlock page when memory controller is disabled.

8<------