"C"表示以编程方式清除Linux机器上的L2缓存 [英] "C" programmatically clear L2 cache on Linux machines

查看:65
本文介绍了"C"表示以编程方式清除Linux机器上的L2缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用"C"编写的与清除Linux OS计算机上的L2缓存相关的编程步骤是什么?

What would be the programmatic steps written in "C" associated with clearing the L2 cache on a Linux OS machine?

/sys/devices/system/cpu/cpu0/cache/index2/size = 6144K x 8CPU

/sys/devices/system/cpu/cpu0/cache/index2/size = 6144K x 8CPUs

推荐答案

您可以通过任何远程清洁/便携式方式获得的最接近的东西:

The closest you can get in any remotely clean/portable way:

char dummy[L2_CACHE_SIZE];
memset(dummy, 0, sizeof dummy);

取决于您的CPU,可能会有特权操作码可以清除缓存,但是我对它们一无所知,也不知道如何访问它们.如果它们存在,您可能仍需要内核级代码才能使用它们.

Depending on your CPU, there may be privileged opcodes that can clear the cache, but I don't know anything about them or how you might access them. It's likely that if they exist, you still might need kernel-level code to use them.

这篇关于"C"表示以编程方式清除Linux机器上的L2缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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