Skip to content

Commit ae8af43

Browse files
koct9itorvalds
authored andcommitted
mm/memcontrol: update lruvec counters in mem_cgroup_move_account
Mapped, dirty and writeback pages are also counted in per-lruvec stats. These counters needs update when page is moved between cgroups. Currently is nobody *consuming* the lruvec versions of these counters and that there is no user-visible effect. Link: http://lkml.kernel.org/r/157112699975.7360.1062614888388489788.stgit@buzz Fixes: 00f3ca2 ("mm: memcontrol: per-lruvec stats infrastructure") Signed-off-by: Konstantin Khlebnikov <[email protected]> Acked-by: Johannes Weiner <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Vladimir Davydov <[email protected] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b918c43 commit ae8af43

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

mm/memcontrol.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5420,6 +5420,8 @@ static int mem_cgroup_move_account(struct page *page,
54205420
struct mem_cgroup *from,
54215421
struct mem_cgroup *to)
54225422
{
5423+
struct lruvec *from_vec, *to_vec;
5424+
struct pglist_data *pgdat;
54235425
unsigned long flags;
54245426
unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1;
54255427
int ret;
@@ -5443,11 +5445,15 @@ static int mem_cgroup_move_account(struct page *page,
54435445

54445446
anon = PageAnon(page);
54455447

5448+
pgdat = page_pgdat(page);
5449+
from_vec = mem_cgroup_lruvec(pgdat, from);
5450+
to_vec = mem_cgroup_lruvec(pgdat, to);
5451+
54465452
spin_lock_irqsave(&from->move_lock, flags);
54475453

54485454
if (!anon && page_mapped(page)) {
5449-
__mod_memcg_state(from, NR_FILE_MAPPED, -nr_pages);
5450-
__mod_memcg_state(to, NR_FILE_MAPPED, nr_pages);
5455+
__mod_lruvec_state(from_vec, NR_FILE_MAPPED, -nr_pages);
5456+
__mod_lruvec_state(to_vec, NR_FILE_MAPPED, nr_pages);
54515457
}
54525458

54535459
/*
@@ -5459,14 +5465,14 @@ static int mem_cgroup_move_account(struct page *page,
54595465
struct address_space *mapping = page_mapping(page);
54605466

54615467
if (mapping_cap_account_dirty(mapping)) {
5462-
__mod_memcg_state(from, NR_FILE_DIRTY, -nr_pages);
5463-
__mod_memcg_state(to, NR_FILE_DIRTY, nr_pages);
5468+
__mod_lruvec_state(from_vec, NR_FILE_DIRTY, -nr_pages);
5469+
__mod_lruvec_state(to_vec, NR_FILE_DIRTY, nr_pages);
54645470
}
54655471
}
54665472

54675473
if (PageWriteback(page)) {
5468-
__mod_memcg_state(from, NR_WRITEBACK, -nr_pages);
5469-
__mod_memcg_state(to, NR_WRITEBACK, nr_pages);
5474+
__mod_lruvec_state(from_vec, NR_WRITEBACK, -nr_pages);
5475+
__mod_lruvec_state(to_vec, NR_WRITEBACK, nr_pages);
54705476
}
54715477

54725478
#ifdef CONFIG_TRANSPARENT_HUGEPAGE

0 commit comments

Comments
 (0)