Commit 21e330fc authored by Shakeel Butt's avatar Shakeel Butt Committed by Linus Torvalds

mm: swap: memcg: fix memcg stats for huge pages

The commit 2262185c ("mm: per-cgroup memory reclaim stats") added
PGLAZYFREE, PGACTIVATE & PGDEACTIVATE stats for cgroups but missed
couple of places and PGLAZYFREE missed huge page handling. Fix that.
Also for PGLAZYFREE use the irq-unsafe function to update as the irq is
already disabled.

Fixes: 2262185c ("mm: per-cgroup memory reclaim stats")
Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Link: http://lkml.kernel.org/r/20200527182947.251343-1-shakeelb@google.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5d91f31f
...@@ -320,6 +320,7 @@ static void __activate_page(struct page *page, struct lruvec *lruvec, ...@@ -320,6 +320,7 @@ static void __activate_page(struct page *page, struct lruvec *lruvec,
{ {
if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
int lru = page_lru_base_type(page); int lru = page_lru_base_type(page);
int nr_pages = hpage_nr_pages(page);
del_page_from_lru_list(page, lruvec, lru); del_page_from_lru_list(page, lruvec, lru);
SetPageActive(page); SetPageActive(page);
...@@ -327,7 +328,9 @@ static void __activate_page(struct page *page, struct lruvec *lruvec, ...@@ -327,7 +328,9 @@ static void __activate_page(struct page *page, struct lruvec *lruvec,
add_page_to_lru_list(page, lruvec, lru); add_page_to_lru_list(page, lruvec, lru);
trace_mm_lru_activate(page); trace_mm_lru_activate(page);
__count_vm_events(PGACTIVATE, hpage_nr_pages(page)); __count_vm_events(PGACTIVATE, nr_pages);
__count_memcg_events(lruvec_memcg(lruvec), PGACTIVATE,
nr_pages);
} }
} }
...@@ -565,8 +568,11 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, ...@@ -565,8 +568,11 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec,
__count_vm_events(PGROTATED, nr_pages); __count_vm_events(PGROTATED, nr_pages);
} }
if (active) if (active) {
__count_vm_events(PGDEACTIVATE, nr_pages); __count_vm_events(PGDEACTIVATE, nr_pages);
__count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE,
nr_pages);
}
} }
static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec, static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec,
...@@ -574,13 +580,16 @@ static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec, ...@@ -574,13 +580,16 @@ static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec,
{ {
if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) {
int lru = page_lru_base_type(page); int lru = page_lru_base_type(page);
int nr_pages = hpage_nr_pages(page);
del_page_from_lru_list(page, lruvec, lru + LRU_ACTIVE); del_page_from_lru_list(page, lruvec, lru + LRU_ACTIVE);
ClearPageActive(page); ClearPageActive(page);
ClearPageReferenced(page); ClearPageReferenced(page);
add_page_to_lru_list(page, lruvec, lru); add_page_to_lru_list(page, lruvec, lru);
__count_vm_events(PGDEACTIVATE, hpage_nr_pages(page)); __count_vm_events(PGDEACTIVATE, nr_pages);
__count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE,
nr_pages);
} }
} }
...@@ -590,6 +599,7 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, ...@@ -590,6 +599,7 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec,
if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) && if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) &&
!PageSwapCache(page) && !PageUnevictable(page)) { !PageSwapCache(page) && !PageUnevictable(page)) {
bool active = PageActive(page); bool active = PageActive(page);
int nr_pages = hpage_nr_pages(page);
del_page_from_lru_list(page, lruvec, del_page_from_lru_list(page, lruvec,
LRU_INACTIVE_ANON + active); LRU_INACTIVE_ANON + active);
...@@ -603,8 +613,9 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, ...@@ -603,8 +613,9 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec,
ClearPageSwapBacked(page); ClearPageSwapBacked(page);
add_page_to_lru_list(page, lruvec, LRU_INACTIVE_FILE); add_page_to_lru_list(page, lruvec, LRU_INACTIVE_FILE);
__count_vm_events(PGLAZYFREE, hpage_nr_pages(page)); __count_vm_events(PGLAZYFREE, nr_pages);
count_memcg_page_event(page, PGLAZYFREE); __count_memcg_events(lruvec_memcg(lruvec), PGLAZYFREE,
nr_pages);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment