You can use the perfcounters subsystem. This is mainly an abstraction of processor performance counters, which are hardware registers that record events such as cache misses, executed instructions, incorrect industry predictions, etc. It also provides an abstraction for software events (sic) such as minor / major page errors, task migrations, switches, and trace points. perf tool can be used to control and verify the correct behavior of the cache - for example, you can check the correctness of work with clearing the cache by filling out caching, clearing, measuring cache misses during subsequent access to the memory and comparing it with the expected result.
source
share