[PATCH/RFC 5/5] numa - migration cache - add statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Migration Cache  5/N - use migration cache for lazy migration

Add migration cache vm statistics.  We might want some statistics
for the migration cache, should it be merged.  Here's a start.

Note:  the '_NOENT stats are mostly for debugging.

Signed-off-by: Lee Schermerhorn <lee.schermerhorn@xxxxxx>

 include/linux/vmstat.h |    5 +++++
 mm/swap_state.c        |   11 +++++++++--
 mm/vmstat.c            |    8 ++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

Index: linux-2.6.36-mmotm-101103-1217/include/linux/vmstat.h
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/include/linux/vmstat.h
+++ linux-2.6.36-mmotm-101103-1217/include/linux/vmstat.h
@@ -65,6 +65,11 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
 		AUTOMIG_TASKS_MIGRATED,
 		AUTOMIG_PGSCANNED, AUTOMIG_PGSELECTED, AUTOMIG_PGFAILED,
 #endif
+#ifdef CONFIG_MIGRATION_CACHE
+		MIGCACHE_ADD, MIGCACHE_REMOVE,
+		MIGCACHE_DUP, MIGCACHE_FREE,
+		MIGCACHE_DUP_NOENT, MIGCACHE_FREE_NOENT,
+#endif
 		NR_VM_EVENT_ITEMS
 };
 
Index: linux-2.6.36-mmotm-101103-1217/mm/swap_state.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/swap_state.c
+++ linux-2.6.36-mmotm-101103-1217/mm/swap_state.c
@@ -123,10 +123,13 @@ int migration_duplicate(swp_entry_t entr
 
 	spin_lock_irq(&migration_space.tree_lock);
 	cnt = idr_find(&migration_idr, (int)swp_offset(entry));
-	if (cnt)
+	if (cnt) {
+		count_vm_event(MIGCACHE_DUP);
 		atomic_inc(&cnt->i);
-	else
+	} else {
+		count_vm_event(MIGCACHE_DUP_NOENT);
 		err = -ENOENT;
+	}
 	spin_unlock_irq(&migration_space.tree_lock);
 	return err;
 }
@@ -197,6 +200,7 @@ static void __remove_from_migration_cach
 
 	radix_tree_delete(&migration_space.page_tree, id);
 	idr_remove(&migration_idr, (int)id);
+	count_vm_event(MIGCACHE_REMOVE);
 }
 
 /*
@@ -219,12 +223,14 @@ void __migration_remove_reference(struct
 	cnt = idr_find(&migration_idr, offset);
 	if (!cnt) {
 		spin_unlock_irq(&migration_space.tree_lock);
+		count_vm_event(MIGCACHE_FREE_NOENT);
 		WARN_ONCE(1, "No migration cache 'id' for entry %d\n", offset);
 		return;
 	}
 
 	VM_BUG_ON(!atomic_read(&cnt->i));
 
+	count_vm_event(MIGCACHE_FREE);
 	if (atomic_sub_and_test(1, &cnt->i)) {
 		__remove_from_migration_cache(page, entry.val);
 		spin_unlock_irq(&migration_space.tree_lock);
@@ -299,6 +305,7 @@ int add_to_migration_cache(struct page *
 			set_page_private(page, entry.val);
 			SetPageSwapCache(page);
 			SetPageUptodate(page);	/* like __add_to_swap() */
+			count_vm_event(MIGCACHE_ADD);
 		}
 		spin_unlock_irq(&migration_space.tree_lock);
 		radix_tree_preload_end();
Index: linux-2.6.36-mmotm-101103-1217/mm/vmstat.c
===================================================================
--- linux-2.6.36-mmotm-101103-1217.orig/mm/vmstat.c
+++ linux-2.6.36-mmotm-101103-1217/mm/vmstat.c
@@ -875,6 +875,14 @@ static const char * const vmstat_text[]
 	"automig_pgs_selected",
 	"automig_pgs_failed",
 #endif
+#ifdef CONFIG_MIGRATION_CACHE
+	"migration_cache_adds",
+	"migration_cache_removes",
+	"migration_cache_dups",
+	"migration_cache_frees",
+	"migration_cache_dup_noent",
+	"migration_cache_free_noent",
+#endif
 #endif
 };
 
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux