Skip to contentSkip to conversation

memcg, THP, swap: avoid to duplicated charge THP in swap cache

PATCH In review [email protected] 1 participant 1 message Sep 6, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 74/119 memcg, THP, swap: avoid to duplicated charge THP in swap cache

From: Huang Ying <[email protected]>
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.

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]>

---

 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c renamed from mm/memcontrol.c~memcg-thp-swap-avoid-to-duplicated-charge-thp-in-swap-cache +1 -1
diff -puN mm/memcontrol.c~memcg-thp-swap-avoid-to-duplicated-charge-thp-in-swap-cache 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) {

_