I am doing some benchmarking and I need to clear the cache before each test. I have this example here:
Caches and Self-Modifying Code
However, I just want to clean the whole cache. Is there an easy way to do that? I do not need to know the start and end address of the functions. I just want some simple code
Thanks.
> The ARMv7-A/R Architecture gives an example sequence for cleaning the entire data and unified cache, using set/way operations
Hmm - this isn't guaranteed to work portably. On a single-core system you'll get away with it, but the set/way maintenance operations are not guaranteed to be SMP-safe. The only "architecturally sound" means to clean/clean-invalidate the cache in an SMP system once it is up and running is use the "by VA" operations.
*EDIT* Also note that by default the data memory allocations returned to an application in Linux is marked "XN" in the MMU (eXecute Never) - the data pages are not executable. IIRC you'll need to make some special memory allocation calls with the kernel to get some executable memory.
HTH,
Pete
So, essentially, I have to use that clean_cache function as in the link in my OP? You wouldn't know of any documentation for that function? Also, I guess I cannot just pass the result of malloc? As discussed here:
How clear and invalidate ARM v7 processor cache from User Mode on Linux 2.6.35 - Stack Overflow
Why is that?