mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 074/119] memcg, THP, swap: avoid to duplicated charge THP in swap cache
@ 2017-09-06 23:22 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-09-06 23:22 UTC (permalink / raw)
  To: aarcange, akpm, axboe, dan.j.williams, hannes, hughd,
	kirill.shutemov, mhocko, minchan, mm-commits, riel, ross.zwisler,
	shli, torvalds, vishal.l.verma, ying.huang

From: Huang Ying <ying.huang@intel.com>
Subject: memcg, THP, swap: avoid to duplicated charge THP in swap cache

For a THP (Transparent Huge Page), tail_page->mem_cgroup is NULL.  So to
check whether the page is charged already, we need to check the head page.
This is not an issue before because it is impossible for a THP to be in
the swap cache before.  But after we add delaying splitting THP after
swapped out support, it is possible now.

Link: http://lkml.kernel.org/r/20170724051840.2309-10-ying.huang@intel.com
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>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Rik van Riel <riel@redhat.com>
Cc: Ross Zwisler <ross.zwisler@intel.com> [for brd.c, zram_drv.c, pmem.c]
Cc: Shaohua Li <shli@kernel.org>
Cc: Vishal L Verma <vishal.l.verma@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN mm/memcontrol.c~memcg-thp-swap-avoid-to-duplicated-charge-thp-in-swap-cache mm/memcontrol.c
--- a/mm/memcontrol.c~memcg-thp-swap-avoid-to-duplicated-charge-thp-in-swap-cache
+++ a/mm/memcontrol.c
@@ -5430,7 +5430,7 @@ int mem_cgroup_try_charge(struct page *p
 		 * in turn serializes uncharging.
 		 */
 		VM_BUG_ON_PAGE(!PageLocked(page), page);
-		if (page->mem_cgroup)
+		if (compound_head(page)->mem_cgroup)
 			goto out;
 
 		if (do_swap_account) {
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-06 23:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 23:22 [patch 074/119] memcg, THP, swap: avoid to duplicated charge THP in swap cache akpm

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).