]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm: memcontrol: rewrite charge API
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 26 Jun 2014 00:42:38 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 26 Jun 2014 00:42:38 +0000 (10:42 +1000)
commitca8ba3173d91e18629458a4d56d63c7c4d222c23
tree7a9f29144e5606612bc8fb85a36343bb43cda8ed
parent9fd2cd8611a3534db2600eda5abfc5d420eaa865
mm: memcontrol: rewrite charge API

The memcg charge API charges pages before they are rmapped - i.e.  have an
actual "type" - and so every callsite needs its own set of charge and
uncharge functions to know what type is being operated on.  Worse,
uncharge has to happen from a context that is still type-specific, rather
than at the end of the page's lifetime with exclusive access, and so
requires a lot of synchronization.

Rewrite the charge API to provide a generic set of try_charge(),
commit_charge() and cancel_charge() transaction operations, much like
what's currently done for swap-in:

  mem_cgroup_try_charge() attempts to reserve a charge, reclaiming
  pages from the memcg if necessary.

  mem_cgroup_commit_charge() commits the page to the charge once it
  has a valid page->mapping and PageAnon() reliably tells the type.

  mem_cgroup_cancel_charge() aborts the transaction.

This reduces the charge API and enables subsequent patches to
drastically simplify uncharging.

As pages need to be committed after rmap is established but before they
are added to the LRU, page_add_new_anon_rmap() must stop doing LRU
additions again.  Revive lru_cache_add_active_or_unevictable().

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
12 files changed:
Documentation/cgroups/memcg_test.txt
include/linux/memcontrol.h
include/linux/swap.h
kernel/events/uprobes.c
mm/filemap.c
mm/huge_memory.c
mm/memcontrol.c
mm/memory.c
mm/rmap.c
mm/shmem.c
mm/swap.c
mm/swapfile.c