memcg: fix Bad page state after replace_page_cache
authorHugh Dickins <hughd@google.com>
Thu, 19 Apr 2012 06:34:46 +0000 (23:34 -0700)
committerVarun Wadekar <vwadekar@nvidia.com>
Wed, 25 Apr 2012 06:17:07 +0000 (11:17 +0530)
commit5ec2f44464836ac27c17a40eefeac2c6a205e355
tree1d8c70bc03ce7d1109de9a528a849f99f2a70a2b
parent2729ab283159562aeb7f2237bfae6ea6e953520a
memcg: fix Bad page state after replace_page_cache

My 9ce70c0240d0 "memcg: fix deadlock by inverting lrucare nesting" put a
nasty little bug into v3.3's version of mem_cgroup_replace_page_cache(),
sometimes used for FUSE.  Replacing __mem_cgroup_commit_charge_lrucare()
by __mem_cgroup_commit_charge(), I used the "pc" pointer set up earlier:
but it's for oldpage, and needs now to be for newpage.  Once oldpage was
freed, its PageCgroupUsed bit (cleared above but set again here) caused
"Bad page state" messages - and perhaps worse, being missed from newpage.
(I didn't find this by using FUSE, but in reusing the function for tmpfs.)

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: stable@vger.kernel.org [v3.3 only]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c