Fred Proctor (me) wrote:
> I'm doing a bunch of jitter and timing tests and I want to disable the Pentium
> cache for some of this.
...
> Does anyone have code that does this that can be run as a user-level program,
> e.g., cacheoff/cacheon?
Laurent Kersten ([EMAIL PROTECTED]) replied to me directly with this
kernel module code. Inserting the module disables the cache (and TLB as
side-effect). Removing it reenables the cache.
---begin cachectl.c---
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
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");
}
---end cachctl.c---
I ran the /proj/jitter test from Stuart Hughes (this is the jitter.tgz
attachment from Stuart's email in the rtlinux mail list archive,
http://www.rtlinux.org/mailing_list/rtl.w5archive/9912/msg00095.html). Jitter
went UP when I disabled the cache. Disabling the cache slows down the computer
by a factor of about 20, so the increased jitter may be due to the magnified
variation in execution time for various branches in the scheduler.
Paolo Mantegazza wrote that he disabled the cache in BIOS:
>
I simply disabled any internal and external cache at the BIOS level. I think any
BIOS can do it.
<
I thought the Linux kernel enabled the cache regardless of the BIOS setting.
True? I'll change the code to printk out the initial CR0 value during
init_module and see. Also, I have the world's lamest BIOS on most of my Dell
computers and can't diddle with the cache anyway.
--Fred
--Fred
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/