From d511c84bb8211b4e20ff6bcaea17b00a4e275a5f Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 8 Apr 2008 04:58:23 +0000 Subject: [PATCH] update git-svn-id: http://ltt.polymtl.ca/svn@2872 04897980-b3bd-0310-b5e0-8ef037075253 --- markers-test/Makefile | 1 + markers-test/cachectl.c | 30 ++++++++++++++++++++++++++++++ markers-test/runtest.sh | 7 +++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 markers-test/cachectl.c diff --git a/markers-test/Makefile b/markers-test/Makefile index 4499bb27..d07a8292 100644 --- a/markers-test/Makefile +++ b/markers-test/Makefile @@ -4,6 +4,7 @@ ifneq ($(KERNELRELEASE),) obj-m += test-mark-speed-edit.o obj-m += test-mark-speed-opt.o obj-m += test-mark-speed-local.o + obj-m += cachectl.o else KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) diff --git a/markers-test/cachectl.c b/markers-test/cachectl.c new file mode 100644 index 00000000..7bbea8a8 --- /dev/null +++ b/markers-test/cachectl.c @@ -0,0 +1,30 @@ +#include +#include + +int init_module() +{ + unsigned tmp; + + /* Disable cache */ + + asm volatile ("movl %%cr0, %0\n\t" + "orl $0x40000000, %0\n\t" + "wbinvd\n\t" + "movl %0, %%cr0\n\t" + "wbinvd\n\t" + : "=r" (tmp) : : "memory"); + + return 0; +} + +void cleanup_module() +{ + unsigned tmp; + + asm volatile ("movl %%cr0, %0\n\t" + "andl $0xbfffffff, %0\n\t" + "wbinvd\n\t" + "movl %0, %%cr0\n\t" + "wbinvd\n\t" + : "=r" (tmp) : : "memory"); +} diff --git a/markers-test/runtest.sh b/markers-test/runtest.sh index 0f290121..986a6e16 100644 --- a/markers-test/runtest.sh +++ b/markers-test/runtest.sh @@ -41,8 +41,10 @@ rmmod test-mark-speed-local RESNOPLOCAL=`dmesg |grep "cycles : " |tail -n 10 |sed 's/^\[.*\] //'| sed 's/cycles : \(.*\)$/\1/'` -make clean -make EXTRA_CFLAGS=-DCACHEFLUSH +#make clean +#make EXTRA_CFLAGS=-DCACHEFLUSH + +modprobe cachectl insmod test-mark-speed-empty.ko cat /proc/testmark @@ -79,6 +81,7 @@ rmmod test-mark-speed-local RESNOPLOCALFL=`dmesg |grep "cycles : " |tail -n 10 |sed 's/^\[.*\] //'| sed 's/cycles : \(.*\)$/\1/'` +rmmod cachectl echo "Results in cycles per loop" -- 2.34.1