--- tests/Makefile | 1 tests/vmstat_test.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) Index: linux-2.6/tests/Makefile =================================================================== --- linux-2.6.orig/tests/Makefile 2007-11-07 19:14:05.000000000 -0800 +++ linux-2.6/tests/Makefile 2007-11-07 19:16:08.000000000 -0800 @@ -1,2 +1,3 @@ obj-m += slub_test.o +obj-m += vmstat_test.o Index: linux-2.6/tests/vmstat_test.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6/tests/vmstat_test.c 2007-11-07 19:33:10.000000000 -0800 @@ -0,0 +1,86 @@ +/* test-vmstat.c + * + * Test module for in kernel synthetic vm statistics performance. + * + * execute + * + * modprobe test-vmstat + * + * to run this test + * + * (C) 2007 SGI, Christoph Lameter + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define TEST_COUNT 10000 + +static int vmstat_test_init(void) +{ + unsigned int i; + cycles_t time1, time2, time; + long rem; + struct page *page = alloc_page(GFP_KERNEL); + + printk(KERN_ALERT "test init\n"); + + printk(KERN_ALERT "Single thread testing\n"); + printk(KERN_ALERT "=====================\n"); + printk(KERN_ALERT "1. inc_zone_page_state() then dec_zone_page_state()\n"); + time1 = get_cycles(); + for (i = 0; i < TEST_COUNT; i++) + inc_zone_page_state(page, NR_BOUNCE); + + time2 = get_cycles(); + time = time2 - time1; + + printk(KERN_ALERT "%i times inc_zone_page_state() ", i); + time = div_long_long_rem(time, TEST_COUNT, &rem); + printk("-> %llu cycles ", time); + + time1 = get_cycles(); + for (i = 0; i < TEST_COUNT; i++) + dec_zone_page_state(page, NR_BOUNCE); + + time2 = get_cycles(); + time = time2 - time1; + + printk("dec "); + time = div_long_long_rem(time, TEST_COUNT, &rem); + printk("-> %llu cycles\n", time); + + printk(KERN_ALERT "2. count_vm_event test\n"); + time1 = get_cycles(); + for (i = 0; i < TEST_COUNT; i++) + count_vm_event(SLABS_SCANNED); + + time2 = get_cycles(); + time = time2 - time1; + + count_vm_events(-TEST_COUNT, SLABS_SCANNED); + printk(KERN_ALERT "%i count_vm_events ", i); + time = div_long_long_rem(time, TEST_COUNT, &rem); + printk("-> %llu cycles\n", time); + __free_page(page); + return -EAGAIN; /* Fail will directly unload the module */ +} + +static void vmstat_test_exit(void) +{ + printk(KERN_ALERT "test exit\n"); +} + +module_init(vmstat_test_init) +module_exit(vmstat_test_exit) + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Christoph Lameter"); +MODULE_DESCRIPTION("VM statistics test"); +