Disabling CPU caches
Hi,
I would like to disable the level 1 and level 2 caches of my CPU. I wrote a kernel module to set the 30th bit of the control register cr0. But when I try to insert the module with insmod, the system freezes. I am using a Thinkpad X41 with a Pentium M and kernel 2.6.32-40-generic #87-Ubuntu SMP. What can I do to determine the reason for the freeze? Thank you for your help! The code of the module: Code:
#include <linux/init.h> Code:
EXTRA_CFLAGS = -m32 Code:
sudo insmod ./disableCache.ko |
As I just found out, the syntax for the mov instruction with control registers is not as I expected: in Intel syntax, the destination register comes first in cases where control registers are involved. I adopted the code of the module in the first post.
However, the overall result stays the same, the system freezes when the module is inserted. I found out that the module runs without problems with this line commented out: Code:
"or eax,(1 << 30)\n\t" Any ideas? |
Any suggestions about an other forum where I can ask? Any hint is appreciated, thanks.
|
You can't disable CPU cache in fly.
|
Disabling cpu caches gives you a pentium I like processor!!!
The addition of Cache on CPU was one of the best upgrades to cpu architecture and is used to retain temporal data / instructions. as nini09 have said, you cannot disable it at fly, but certain BIOS would give you the option at boot time. Is there any special requirement, or is only homework / test? |
It can be done this is from memtest
Code:
static inline void cache_off(void) |
Thank you for your answers. I want to disable the caches for a research project where we want to measure execution times and want to be sure they are not influenced by the internal caches.
@whizje: I tried your suggestion and apparently, it is working. :) But I have to investigate it further tomorrow when I will have more time. |
After some investigation, I found out that the module runs fine (with the corrections from my second post). I just didn't wait long enough after fixing the mov cr0, eax bug, misinterpreating the slow behavior of the system with disabled caches as a complete freeze. My apologies for that.
The code posted by whizje is also working, of course. I didn't find an option for cache disabling in the BIOS of my machine. Thanks for your input. |
how to run the above segment of codes....thanks
i am trying to disable the caches ...i want to know how the above code works and how to execute it
|
@hga Run make and insmod. Source code, makefile and argument for insmod is given in the first post. If you have problems, please ask more specific questions.
|
can you be more specfic with the steps...where is to be the code saved and with what extension? thank you.
|
I would suggest to save the source code (in an arbitrary directory) in a file named
Code:
disableCache.c Code:
Makefile Code:
make all Code:
sudo insmod ./disableCache.ko |
i saved the above files and tried the make command. But it displays
make: Nothing to be done for `all'..... Can you help me??? ---------- Post added 07-31-12 at 07:42 AM ---------- i saved the above files and tried the make command. But it displays make: Nothing to be done for `all'..... Can you help me??? |
I have no idea, I have only a very basic knowledge of make...
|
Hi naam,
It look like your makefile has problem. You can make Hello module work at first and then deal with disableCache.c |
All times are GMT -5. The time now is 03:33 PM. |