Skip to content

Commit

Permalink
mm: workingset: add vmstat counter for shadow nodes
Browse files Browse the repository at this point in the history
Make it easier to catch bugs in the shadow node shrinker by adding a
counter for the shadow nodes in circulation.

[[email protected]: assert that irqs are disabled, for __inc_lruvec_page_state()]
[[email protected]: s/WARN_ON_ONCE/VM_WARN_ON_ONCE/, per Johannes]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Johannes Weiner <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Rik van Riel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hnaz authored and torvalds committed Oct 26, 2018
1 parent 505802a commit 68d48e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ enum node_stat_item {
NR_SLAB_UNRECLAIMABLE,
NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
WORKINGSET_NODES,
WORKINGSET_REFAULT,
WORKINGSET_ACTIVATE,
WORKINGSET_RESTORE,
Expand Down
1 change: 1 addition & 0 deletions mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ const char * const vmstat_text[] = {
"nr_slab_unreclaimable",
"nr_isolated_anon",
"nr_isolated_file",
"workingset_nodes",
"workingset_refault",
"workingset_activate",
"workingset_restore",
Expand Down
14 changes: 12 additions & 2 deletions mm/workingset.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,20 @@ void workingset_update_node(struct radix_tree_node *node)
* already where they should be. The list_empty() test is safe
* as node->private_list is protected by the i_pages lock.
*/
VM_WARN_ON_ONCE(!irqs_disabled()); /* For __inc_lruvec_page_state */

if (node->count && node->count == node->exceptional) {
if (list_empty(&node->private_list))
if (list_empty(&node->private_list)) {
list_lru_add(&shadow_nodes, &node->private_list);
__inc_lruvec_page_state(virt_to_page(node),
WORKINGSET_NODES);
}
} else {
if (!list_empty(&node->private_list))
if (!list_empty(&node->private_list)) {
list_lru_del(&shadow_nodes, &node->private_list);
__dec_lruvec_page_state(virt_to_page(node),
WORKINGSET_NODES);
}
}
}

Expand Down Expand Up @@ -473,6 +481,8 @@ 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);

spin_unlock(lru_lock);

/*
Expand Down

0 comments on commit 68d48e6

Please sign in to comment.