linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Huang Ying <ying.huang@intel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Minchan Kim <minchan@kernel.org>,
	Michal Hocko <mhocko@kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
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	[thread overview]
Message-ID: <20170724051840.2309-9-ying.huang@intel.com> (raw)
In-Reply-To: <20170724051840.2309-1-ying.huang@intel.com>

From: Huang Ying <ying.huang@intel.com>

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" <ying.huang@intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
---
 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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-07-24  5:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  5:18 [PATCH -mm -v3 00/12] mm, THP, swap: Delay splitting THP after swapped out Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 01/12] mm, THP, swap: Support to clear swap cache flag for THP " Huang, Ying
2017-07-25 16:39   ` Rik van Riel
2017-07-24  5:18 ` [PATCH -mm -v3 02/12] mm, THP, swap: Support to reclaim swap space " Huang, Ying
2017-07-25 17:47   ` Rik van Riel
2017-07-24  5:18 ` [PATCH -mm -v3 03/12] mm, THP, swap: Make reuse_swap_page() works " Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 04/12] mm, THP, swap: Don't allocate huge cluster for file backed swap device Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 05/12] block, THP: Make block_device_operations.rw_page support THP Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 06/12] Test code to write THP to swap device as a whole Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 07/12] mm, THP, swap: Support to split THP for THP swapped out Huang, Ying
2017-07-24  5:18 ` Huang, Ying [this message]
2017-07-24  5:18 ` [PATCH -mm -v3 09/12] memcg, THP, swap: Avoid to duplicated charge THP in swap cache Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 10/12] memcg, THP, swap: Make mem_cgroup_swapout() support THP Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 11/12] mm, THP, swap: Delay splitting THP after swapped out Huang, Ying
2017-07-24  5:18 ` [PATCH -mm -v3 12/12] mm, THP, swap: Add THP swapping out fallback counting Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170724051840.2309-9-ying.huang@intel.com \
    --to=ying.huang@intel.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).