Skip to content

Commit 68d48e6

Browse files
hnaztorvalds
authored andcommitted
mm: workingset: add vmstat counter for shadow nodes
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]>
1 parent 505802a commit 68d48e6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

include/linux/mmzone.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ enum node_stat_item {
161161
NR_SLAB_UNRECLAIMABLE,
162162
NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
163163
NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
164+
WORKINGSET_NODES,
164165
WORKINGSET_REFAULT,
165166
WORKINGSET_ACTIVATE,
166167
WORKINGSET_RESTORE,

mm/vmstat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ const char * const vmstat_text[] = {
11431143
"nr_slab_unreclaimable",
11441144
"nr_isolated_anon",
11451145
"nr_isolated_file",
1146+
"workingset_nodes",
11461147
"workingset_refault",
11471148
"workingset_activate",
11481149
"workingset_restore",

mm/workingset.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,20 @@ void workingset_update_node(struct radix_tree_node *node)
377377
* already where they should be. The list_empty() test is safe
378378
* as node->private_list is protected by the i_pages lock.
379379
*/
380+
VM_WARN_ON_ONCE(!irqs_disabled()); /* For __inc_lruvec_page_state */
381+
380382
if (node->count && node->count == node->exceptional) {
381-
if (list_empty(&node->private_list))
383+
if (list_empty(&node->private_list)) {
382384
list_lru_add(&shadow_nodes, &node->private_list);
385+
__inc_lruvec_page_state(virt_to_page(node),
386+
WORKINGSET_NODES);
387+
}
383388
} else {
384-
if (!list_empty(&node->private_list))
389+
if (!list_empty(&node->private_list)) {
385390
list_lru_del(&shadow_nodes, &node->private_list);
391+
__dec_lruvec_page_state(virt_to_page(node),
392+
WORKINGSET_NODES);
393+
}
386394
}
387395
}
388396

@@ -473,6 +481,8 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
473481
}
474482

475483
list_lru_isolate(lru, item);
484+
__dec_lruvec_page_state(virt_to_page(node), WORKINGSET_NODES);
485+
476486
spin_unlock(lru_lock);
477487

478488
/*

0 commit comments

Comments
 (0)