Skip to content

Commit 3e14a57

Browse files
yhuang-inteltorvalds
authored andcommitted
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]>
1 parent 5980768 commit 3e14a57

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mm/memcontrol.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4639,8 +4639,11 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
46394639
if (!ret || !target)
46404640
put_page(page);
46414641
}
4642-
/* There is a swap entry and a page doesn't exist or isn't charged */
4643-
if (ent.val && !ret &&
4642+
/*
4643+
* There is a swap entry and a page doesn't exist or isn't charged.
4644+
* But we cannot move a tail-page in a THP.
4645+
*/
4646+
if (ent.val && !ret && (!page || !PageTransCompound(page)) &&
46444647
mem_cgroup_id(mc.from) == lookup_swap_cgroup_id(ent)) {
46454648
ret = MC_TARGET_SWAP;
46464649
if (target)

0 commit comments

Comments
 (0)