Linux 下如何禁用CPU cache
2012-12-18 17:33
645 查看
The code of the module:
Code:
And the Makefile:
Code:
insmod command:
Code:
如果是64位系统,则make file中 -m32 改为-m64同时code 中所有的eax改为rax.
Code:
#include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int disableCache_init(void) { printk(KERN_ALERT "Disabling L1 and L2 caches.\n"); __asm__(".intel_syntax noprefix\n\t" "mov eax,cr0\n\t" "or eax,(1 << 30)\n\t" "mov cr0,eax\n\t" "wbinvd\n\t" ".att_syntax noprefix\n\t" : : : "eax" ); return 0; } static void disableCache_exit(void) { printk(KERN_ALERT "Enabling L1 and L2 caches.\n"); __asm__(".intel_syntax noprefix\n\t" "mov eax,cr0\n\t" "and eax,~(1 << 30)\n\t" "mov cr0,eax\n\t" "wbinvd\n\t" ".att_syntax noprefix\n\t" : : : "eax" ); } module_init(disableCache_init); module_exit(disableCache_exit);
And the Makefile:
Code:
EXTRA_CFLAGS = -m32 obj-m += disableCache.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
insmod command:
Code:
sudo insmod ./disableCache.ko
如果是64位系统,则make file中 -m32 改为-m64同时code 中所有的eax改为rax.
相关文章推荐
- 如何查看linux系统CPU利用率
- Linux如何查看当前占用CPU或内存最多的K个进程
- Linux 有问必答:如何在wget中禁用HTTP转发
- linux 如何禁用账号和解除禁用账号
- linux下如何获取cpu的利用率
- 如何利用多核CPU来加速你的Linux命令 — awk, sed, bzip2, grep, wc等
- linux下top命令如何查看内存及多核CPU的方法
- Linux如何统计进程的CPU利用率
- CentOS7中如何让Linux在启动时就将CPU分离并将hugepage设置为初始1GB
- linux:如何指定进程运行的CPU
- Linux下如何查看高CPU占用率线程
- Linux下如何通过编程读取cpu温度?
- Linux如何查看当前占用CPU或内存最多的几个进程
- Linux下如何查看CPU的数量
- 如何查看linux系统CPU利用率
- linux下如何获取cpu的利用率
- Linux下如何查看CPU信息, 包括位数和多核信息
- linux下使用如何使用多个CPU核
- linux下如何禁用root账户直接登陆
- linux下如何查看CPU数量或核数