本文介绍了启用/英特尔64位计算机上禁用缓存:CD位始终设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图禁用缓存的所有级别我的机器英特尔(R)至强(R)CPU E5-1650 V2 @ 3.50GHz Xen中。我写了一个工具来调用下面的组装code禁用/启用缓存,并显示CR0寄存器的值。

I'm trying to disable all level of cache for my machine Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz in Xen. I wrote a tool to call the following assemble code to disable/enable the cache and show the CR0 register's value.

case XENMEM_disable_cache:
    __asm__ __volatile__(
        "pushq %%rax\n\t"
        "movq %%cr0,%%rax\n\t"
        "orq $0x40000000,%%rax\n\t"
        "movq %%rax,%%cr0\n\t"
        "movq %%cr0, %0\n\t"
        "wbinvd\n\t"
        "popq  %%rax"
        : "=r"(cr0)
        :
        :);
    // gdprintk(XENLOG_WARNING, "gdprintk:XENMEM_disable_cache disable cache!
    // TODO IMPLEMENT\n");
    printk("<1>printk: disable cache! cr0=%#018lx\n", cr0);
    rc = 0;
    break;

case XENMEM_enable_cache:
    __asm__ __volatile__(
        "pushq %%rax\n\t"
        "movq %%cr0,%%rax\n\t"
        "andq $0xffffffffbfffffff,%%rax\n\t" /*~0x4000000*/
        "movq %%rax,%%cr0\n\t"
        "movq %%cr0, %0\n\t"
        "popq  %%rax"
        : "=r"(cr0)
        :
        :);
    printk("<1>printk: enable cache; cr0=%#018lx\n", cr0);
    rc = 0;
    break;

case XENMEM_show_cache:
    __asm__ __volatile__(
        "pushq %%rax\n\t"
        "movq %%cr0, %%rax\n\t"
        "movq %%rax, %0\n\t"
        "popq %%rax"
        : "=r"(cr0)
        :
        :);
    // gdprintk(XENLOG_WARNING, "gdprintk:XENMEM_show_cache_status! CR0 value is
    // %#018lx\n", cr0);
    printk("<1>printk: XENMEM_show_cache_status! CR0 value is %#018lx\n", cr0);
    return (long)cr0;

在code可以编译和运行。我跑了禁用缓存code后,系统会变得极为缓慢,这印证了缓存被禁用。此外,CR0的值显示当我运行禁用缓存code中的CD位设置。

The code can compile and run. After I run the disable cache code, the system becomes extremely slow, which confirms the cache is disabled. In addition, the value of CR0 shows the CD bit is set when I run the disable cache code.

然而,当我运行显示缓存code,输出显示CR0的CD位为0,不管我禁用/启用缓存。

However, when I run the show cache code, the output shows the CD bit of CR0 is 0, no matter I disable/enable cache.

我的问题是:

是CR0寄存器的CD位(30bit的)总是置1时,高速缓存被禁用?

Is the CD bit(30bit) of CR0 register always set 1 when cache is disabled?

如果没有,一定有什么毛病我的code,你可以请帮我指出我做出了错误?

If not, there must be something wrong with my code, could you please help me point out the error I made?

答:

以上code中的code运行时只在那里设置核心CR0寄存器的CD位。我们需要使用smp_call_function()调用code上的所有核心!

The above code only set the CD bit of the CR0 register on the core where the code is running. We need to use the smp_call_function() to call the code on all cores!

我的新问题是:

如果我禁用缓存,然后使用上述code启用缓存,CR0的CD位清零。然而,该系统的性能还是非常非常慢,就像当我禁用缓存。所以,在我看来,启用缓存code不工作?然而,由于CD位已被清除,启用缓存code应该有工作!所以,问题是:多久我应该等待后,我让缓存,这样我可以有同样的表现就像在演出前我禁用缓存

If I disable cache and then enable cache using the above code, the CD bit of CR0 is cleared. However, the system's performance is still very very slow, just like when I disable the cache. So it seems to me that enabling the cache code does NOT work? However, since CD bit has been cleared, the enabling cache code should have worked! So the question is: How long should I wait after I enable cache so that I can have the same performance just like the performance before I disable cache?

顺便说一句,当我运行enble缓存code时,printk的输出显示CR0的CD位为0。

BTW, when I run the enble cache code, the printk output shows that the CR0's CD bit is 0.

推荐答案

如果你是在SMP系统上,你应该调用禁用缓存code与每核心smp_call_function() ,因为它在理论上是可能的,你的节目缓存code是一个不同的处理器上运行。要使用该功能,的#include&LT;在include / linux / smp.h方式&gt;

If you're on an SMP system, you should invoke the disable-cache code for every core with smp_call_function(), since it is theoretically possible that your show-cache code is running on a different processor. To use that function, #include <include/linux/smp.h>.

编辑: smp_call_function()调用函数指针它被赋予只的其它内核的,不是的当前的。确保自己调用函数的调用 smp_call_function()核心上运行的所有核心功能

smp_call_function() invokes the function pointer it is given only on other cores, not on the current one. Make sure to run the function on all cores by invoking the function yourself on the core that invokes smp_call_function().

这篇关于启用/英特尔64位计算机上禁用缓存:CD位始终设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:50