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
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.
You cannot access low level memory from user space, you must implement your own device driver to have access to physical memory in Linux.