diff options
author | Huang Ying <[email protected]> | 2017-09-06 16:22:37 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2017-09-06 17:27:28 -0700 |
commit | 3e14a57b2416b7c94189b95baffd673cf5e0d0a3 (patch) | |
tree | 96df290247cf43720b25ce285945dce0f8eeeaae | |
parent | 59807685a7e77e8c8fe5925613968841538d53d7 (diff) |
memcg, THP, swap: support move mem cgroup charge for THP swapped out
PTE mapped THP (Transparent Huge Page) will be ignored when moving
memory cgroup charge. But for THP which is in the swap cache, the
memory cgroup charge for the swap of a tail-page may be moved in current
implementation. That isn't correct, because the swap charge for all
sub-pages of a THP should be moved together. Following the processing
of the PTE mapped THP, the mem cgroup charge moving for the swap entry
for a tail-page of a THP is ignored too.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: "Huang, Ying" <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: "Kirill A . Shutemov" <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Ross Zwisler <[email protected]> [for brd.c, zram_drv.c, pmem.c]
Cc: Shaohua Li <[email protected]>
Cc: Vishal L Verma <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/memcontrol.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3d3f7b1686ac..2ae315e4d9f6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4639,8 +4639,11 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma, if (!ret || !target) put_page(page); } - /* There is a swap entry and a page doesn't exist or isn't charged */ - if (ent.val && !ret && + /* + * There is a swap entry and a page doesn't exist or isn't charged. + * But we cannot move a tail-page in a THP. + */ + if (ent.val && !ret && (!page || !PageTransCompound(page)) && mem_cgroup_id(mc.from) == lookup_swap_cgroup_id(ent)) { ret = MC_TARGET_SWAP; if (target) |