Skip to content

Commit 7ae8853

Browse files
Yang Shitorvalds
authored andcommitted
mm: move mem_cgroup_uncharge out of __page_cache_release()
A later patch makes THP deferred split shrinker memcg aware, but it needs page->mem_cgroup information in THP destructor, which is called after mem_cgroup_uncharge() now. So move mem_cgroup_uncharge() from __page_cache_release() to compound page destructor, which is called by both THP and other compound pages except HugeTLB. And call it in __put_single_page() for single order page. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Yang Shi <[email protected]> Suggested-by: "Kirill A . Shutemov" <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Kirill Tkhai <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: David Rientjes <[email protected]> Cc: Qian Cai <[email protected]> Cc: Vladimir Davydov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 364c1ee commit 7ae8853

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

mm/page_alloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ static void bad_page(struct page *page, const char *reason,
670670

671671
void free_compound_page(struct page *page)
672672
{
673+
mem_cgroup_uncharge(page);
673674
__free_pages_ok(page, compound_order(page));
674675
}
675676

mm/swap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ static void __page_cache_release(struct page *page)
7171
spin_unlock_irqrestore(&pgdat->lru_lock, flags);
7272
}
7373
__ClearPageWaiters(page);
74-
mem_cgroup_uncharge(page);
7574
}
7675

7776
static void __put_single_page(struct page *page)
7877
{
7978
__page_cache_release(page);
79+
mem_cgroup_uncharge(page);
8080
free_unref_page(page);
8181
}
8282

mm/vmscan.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,10 +1487,9 @@ static unsigned long shrink_page_list(struct list_head *page_list,
14871487
* Is there need to periodically free_page_list? It would
14881488
* appear not as the counts should be low
14891489
*/
1490-
if (unlikely(PageTransHuge(page))) {
1491-
mem_cgroup_uncharge(page);
1490+
if (unlikely(PageTransHuge(page)))
14921491
(*get_compound_page_dtor(page))(page);
1493-
} else
1492+
else
14941493
list_add(&page->lru, &free_pages);
14951494
continue;
14961495

@@ -1911,7 +1910,6 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec,
19111910

19121911
if (unlikely(PageCompound(page))) {
19131912
spin_unlock_irq(&pgdat->lru_lock);
1914-
mem_cgroup_uncharge(page);
19151913
(*get_compound_page_dtor(page))(page);
19161914
spin_lock_irq(&pgdat->lru_lock);
19171915
} else

0 commit comments

Comments
 (0)