From 31d375f53965ffd00fb78cf7217c35ea56405445 Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 19 Mar 2007 03:55:36 +0000 Subject: [PATCH] add teest tsc sync git-svn-id: http://ltt.polymtl.ca/svn@2436 04897980-b3bd-0310-b5e0-8ef037075253 --- tests/kernel/Makefile | 25 ++++++++------- tests/kernel/test-tsc-sync.c | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 tests/kernel/test-tsc-sync.c diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile index 13af7220..541f917a 100644 --- a/tests/kernel/Makefile +++ b/tests/kernel/Makefile @@ -1,22 +1,25 @@ ifneq ($(KERNELRELEASE),) ifneq ($(CONFIG_LTT),) - obj-m += ltt-facility-loader-tests.o -# obj-m += test-time-probe.o - obj-m += test-time-probe2.o - obj-m += test-compact.o + #obj-m += ltt-facility-loader-tests.o +# #obj-m += test-time-probe.o + #obj-m += test-time-probe2.o + #obj-m += test-compact.o # obj-m += ltt-facility-loader-compact.o # obj-m += test-instrument-size-small.o # obj-m += test-instrument-size-med.o # obj-m += test-instrument-size-big.o # obj-m += test-printk-effect.o endif - obj-m += test-debugfs.o + obj-m += test-async-tsc.o + obj-m += test-tsc-sync.o + obj-m += test-hpet.o + #obj-m += test-debugfs.o # obj-m += test-mod.o # obj-m += atomic-pIII-cmx.o - obj-m += test-hotplug.o - obj-m += rdtsc-smp.o - obj-m += test-local.o - obj-m += test-ser.o + #obj-m += test-hotplug.o + #obj-m += rdtsc-smp.o + #obj-m += test-local.o + #obj-m += test-ser.o # obj-m += test-cmpxchg.o # obj-m += test-cmpxchg-nolock.o # obj-m += test-spinlock.o @@ -28,8 +31,8 @@ endif #obj-m += test-kprobes.o #obj-m += test-printk.o #obj-m += test-debugfs.o - obj-m += test-mark.o - obj-m += test-markxmc.o + #obj-m += test-mark.o + #obj-m += test-markxmc.o # obj-m += probe.o # obj-m += test-irqloop.o #obj-m += marker-loader.o diff --git a/tests/kernel/test-tsc-sync.c b/tests/kernel/test-tsc-sync.c new file mode 100644 index 00000000..5ca7e57e --- /dev/null +++ b/tests/kernel/test-tsc-sync.c @@ -0,0 +1,61 @@ +/* test-tsc-sync.c + * + * Test TSC sync + */ + + +#include +#include +#include +#include + +static DEFINE_PER_CPU(cycles_t, count) = 0; + +static struct timer_list test_timer; + +/* IPI called on each CPU. */ +static void test_each(void *info) +{ + __get_cpu_var(count) = get_cycles(); +} + +static void do_test_timer(unsigned long data) +{ + int cpu; + + /* Increment the counters */ + on_each_cpu(test_each, NULL, 0, 1); + /* Read all the counters */ + printk("Counters read from CPU %d\n", smp_processor_id()); + for_each_online_cpu(cpu) { + printk("Read : CPU %d, count %llu\n", cpu, + per_cpu(count, cpu)); + } + del_timer(&test_timer); + test_timer.expires = jiffies + 1000; + add_timer(&test_timer); +} + +static int __init test_init(void) +{ + /* initialize the timer that will increment the counter */ + init_timer(&test_timer); + test_timer.function = do_test_timer; + test_timer.expires = jiffies + 1; + add_timer(&test_timer); + + return 0; +} + +static void __exit test_exit(void) +{ + del_timer_sync(&test_timer); +} + +module_init(test_init); +module_exit(test_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("sync tsc test"); + -- 2.34.1