mm: workingset: fix vmstat counters for shadow nodes
Memcg counters for shadow nodes are broken because the memcg pointer is obtained in a wrong way. The following approach is used: virt_to_page(xa_node)->mem_cgroup Since commit4d96ba3530
("mm: memcg/slab: stop setting page->mem_cgroup pointer for slab pages") page->mem_cgroup pointer isn't set for slab pages, so memcg_from_slab_page() should be used instead. Also I doubt that it ever worked correctly: virt_to_head_page() should be used instead of virt_to_page(). Otherwise objects residing on tail pages are not accounted, because only the head page contains a valid mem_cgroup pointer. That was a case since the introduction of these counters by the commit68d48e6a2d
("mm: workingset: add vmstat counter for shadow nodes"). Link: http://lkml.kernel.org/r/20190801233532.138743-1-guro@fb.com Fixes:4d96ba3530
("mm: memcg/slab: stop setting page->mem_cgroup pointer for slab pages") Signed-off-by: Roman Gushchin <guro@fb.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: Shakeel Butt <shakeelb@google.com> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
951531691c
commit
ec9f02384f
@@ -380,14 +380,12 @@ void workingset_update_node(struct xa_node *node)
|
||||
if (node->count && node->count == node->nr_values) {
|
||||
if (list_empty(&node->private_list)) {
|
||||
list_lru_add(&shadow_nodes, &node->private_list);
|
||||
__inc_lruvec_page_state(virt_to_page(node),
|
||||
WORKINGSET_NODES);
|
||||
__inc_lruvec_slab_state(node, WORKINGSET_NODES);
|
||||
}
|
||||
} else {
|
||||
if (!list_empty(&node->private_list)) {
|
||||
list_lru_del(&shadow_nodes, &node->private_list);
|
||||
__dec_lruvec_page_state(virt_to_page(node),
|
||||
WORKINGSET_NODES);
|
||||
__dec_lruvec_slab_state(node, WORKINGSET_NODES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,7 +478,7 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
|
||||
}
|
||||
|
||||
list_lru_isolate(lru, item);
|
||||
__dec_lruvec_page_state(virt_to_page(node), WORKINGSET_NODES);
|
||||
__dec_lruvec_slab_state(node, WORKINGSET_NODES);
|
||||
|
||||
spin_unlock(lru_lock);
|
||||
|
||||
@@ -503,7 +501,7 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
|
||||
* shadow entries we were tracking ...
|
||||
*/
|
||||
xas_store(&xas, NULL);
|
||||
__inc_lruvec_page_state(virt_to_page(node), WORKINGSET_NODERECLAIM);
|
||||
__inc_lruvec_slab_state(node, WORKINGSET_NODERECLAIM);
|
||||
|
||||
out_invalid:
|
||||
xa_unlock_irq(&mapping->i_pages);
|
||||
|
Reference in New Issue
Block a user