]> Git Repo - linux.git/commit - mm/rmap.c
ksm: share anon page without allocating
authorHugh Dickins <[email protected]>
Tue, 15 Dec 2009 01:59:29 +0000 (17:59 -0800)
committerLinus Torvalds <[email protected]>
Tue, 15 Dec 2009 16:53:19 +0000 (08:53 -0800)
commit80e148226028257ec0a1909d99b2c40d0ffe17f2
tree1e3cae42144f5c80e215ba254e01bd6847ba1b36
parent4035c07a895974d0ac06a56fe870ad293fc451a7
ksm: share anon page without allocating

When ksm pages were unswappable, it made no sense to include them in mem
cgroup accounting; but now that they are swappable (although I see no
strict logical connection) the principle of least surprise implies that
they should be accounted (with the usual dissatisfaction, that a shared
page is accounted to only one of the cgroups using it).

This patch was intended to add mem cgroup accounting where necessary; but
turned inside out, it now avoids allocating a ksm page, instead upgrading
an anon page to ksm - which brings its existing mem cgroup accounting with
it.  Thus mem cgroups don't appear in the patch at all.

This upgrade from PageAnon to PageKsm takes place under page lock (via a
somewhat hacky NULL kpage interface), and audit showed only one place
which needed to cope with the race - page_referenced() is sometimes used
without page lock, so page_lock_anon_vma() needs an ACCESS_ONCE() to be
sure of getting anon_vma and flags together (no problem if the page goes
ksm an instant after, the integrity of that anon_vma list is unaffected).

Signed-off-by: Hugh Dickins <[email protected]>
Cc: Izik Eidus <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Chris Wright <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/ksm.c
mm/rmap.c
This page took 0.057964 seconds and 4 git commands to generate.