WBINVD指令使用 [英] WBINVD instruction usage

查看:1154
本文介绍了WBINVD指令使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Linux上的WBINV指令清除处理器的L1缓存。

I'm trying to use the WBINV instruction on linux to clear the processor's L1 cache.

下面的程序编译,但会产生分段错误,当我尝试运行它。

The following program compiles, but produces a segmentation fault when I try to run it.

INT的main(){ASM(WBINVD);返回1;}

我使用gcc 4.4.3和我的x86机器上运行Linux内核2.6.32-33。

I'm using gcc 4.4.3 and run Linux kernel 2.6.32-33 on my x86 box.

处理器信息:英特尔(R)酷睿(TM)2双核CPU T5270 @ 1.40GHz

Processor info: Intel(R) Core(TM)2 Duo CPU T5270 @ 1.40GHz

我建立的程序如下:

$ GCC

$ ./a.out

$ ./a.out

分段错误

有人能告诉我什么,我做错了什么?我如何得到这个运行?

Can somebody tell me what I'm doing wrong? How do I get this to run?

P.S:我运行几个性能测试,并希望确保该处理器的高速缓存的previous内容不影响结果。

P.S: I'm running a few performance tests and want to ensure that the previous content of the processor cache does not influence the results.

推荐答案

英特尔®64和IA-32架构软件开发人员手册
综合卷2A和2B:指令集参考,A-Z :

该指令WBINVD是特权指令。当处理器在运行
  保护模式,程序或过程的CPL必须是0才能执行此
  指令。

The WBINVD instruction is a privileged instruction. When the processor is running in protected mode, the CPL of a program or procedure must be 0 to execute this instruction.

在换句话说只有内核模式code被允许执行它。

In other words only kernel mode code is allowed to execute it.

编辑:previous等清除缓存讨论:

Previous SO discussion on clearing caches:

<一个href=\"http://stackoverflow.com/questions/3453995/c-programmatically-clear-l2-cache-on-linux-machines\">"C"在Linux机器上编程明确的L2缓存

CPU缓存刷新

如何清除CPU的L1和L2缓存

如何清除CPU的L1和L2缓存

这篇关于WBINVD指令使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆