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 8CPUs
The closest you can get in any remotely clean/portable way:
char dummy[L2_CACHE_SIZE];
memset(dummy, 0, sizeof dummy);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With