tags:

views:

114

answers:

2

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

A: 

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.

R..
And that means we might find a syscall to perform the task in question.
Basilevs
A: 

You cannot access low level memory from user space, you must implement your own device driver to have access to physical memory in Linux.

AmineK