From f1329bccc76f3e6bb56c59d7892446e3f636e834 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 9 Nov 2007 19:15:54 -0800 Subject: [PATCH] Vm statistics performance test Tests the performance of some key vm statistics functions. Signed-off-by: Christoph Lameter --- tests/Makefile | 1 + tests/vmstat_test.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 0 deletions(-) create mode 100644 tests/vmstat_test.c diff --git a/tests/Makefile b/tests/Makefile index a6c4f07..f4ca829 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,2 +1,3 @@ obj-m += slub_test.o +obj-m += vmstat_test.o diff --git a/tests/vmstat_test.c b/tests/vmstat_test.c new file mode 100644 index 0000000..aada6d5 --- /dev/null +++ b/tests/vmstat_test.c @@ -0,0 +1,98 @@ +/* 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 "VMstat 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_z_p_s() "); + time = div_long_long_rem(time, TEST_COUNT, &rem); + printk("-> %llu cycles\n", time); + + printk(KERN_ALERT "2. inc_zone_page_state()/dec_zone_page_state()\n"); + time1 = get_cycles(); + for (i = 0; i < TEST_COUNT; i++) { + inc_zone_page_state(page, NR_BOUNCE); + dec_zone_page_state(page, NR_BOUNCE); + } + + time2 = get_cycles(); + time = time2 - time1; + + printk(KERN_ALERT "%i times inc/dec ", i); + time = div_long_long_rem(time, TEST_COUNT, &rem); + printk("-> %llu cycles\n", time); + + printk(KERN_ALERT "3. count_vm_event()\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(SLABS_SCANNED, -TEST_COUNT); + 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"); + -- 1.5.5.1