Testing cache invalidation and flush
So after programming the basic L1 and L2 cache related routines in Linux kernel (arch/arm/mm/cache-X.S
) say for example specific to ARM11 Processor, is there a 开发者_如何学Gotest utility/program available to test whether the cache is working properly such that invalidation, flush happens properly. How we can ensure it instead of just relying on our own programs.
You can use the perfcounters subsystem. It's basically an abstraction over CPU performance counters, which are hardware registers recording events like cache misses, instructions executed, branch mispredictions etc. It also provides abstraction for software events (sic) such as minor/major page faults, task migrations, task context-switches and tracepoints. The perf
tool can be used to monitor and verify correct cache behaviour - for instance, you can check cache flushing works correctly by filling the cache, flushing it, measuring cache misses on subsequent memory accesses and comparing it to your expected result.
You can have a look to LMBench a deep benchmark that can be run on almost every linux platform (I already successly used it on x86, ARM9 and CortexA8 architectures). You'll be able to measure cache performance.
If your cache is using the RAM, you can flush the Linux RAM:
echo "1" > /proc/sys/vm/drop_caches
echo "0" > /proc/sys/vm/drop_caches
free -m
精彩评论