Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbdGXFVD (ORCPT ); Mon, 24 Jul 2017 01:21:03 -0400 Received: from mga04.intel.com ([192.55.52.120]:38144 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbdGXFTC (ORCPT ); Mon, 24 Jul 2017 01:19:02 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,405,1496127600"; d="scan'208";a="290458739" From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Johannes Weiner , Minchan Kim , Michal Hocko , Andrea Arcangeli , "Kirill A . Shutemov" Subject: [PATCH -mm -v3 08/12] memcg, THP, swap: Support move mem cgroup charge for THP swapped out Date: Mon, 24 Jul 2017 13:18:36 +0800 Message-Id: <20170724051840.2309-9-ying.huang@intel.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170724051840.2309-1-ying.huang@intel.com> References: <20170724051840.2309-1-ying.huang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1527 Lines: 40 From: Huang Ying 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. Signed-off-by: "Huang, Ying" Cc: Johannes Weiner Cc: Minchan Kim Cc: Michal Hocko Cc: Andrea Arcangeli Cc: "Kirill A . Shutemov" --- mm/memcontrol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3df3c04d73ab..c2618bd8ebdd 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4616,8 +4616,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) -- 2.13.2