How to flush the CPU cache for a region of address space in Linux?

前端 未结 5 1010
你的背包
你的背包 2020-12-01 05:04

I am interested in flushing cache (L1, L2, and L3) only for a region of address space, for example all cache entries from address A to address B. Is there a mechanism to do

5条回答
  •  长情又很酷
    2020-12-01 05:25

    This is for ARM.

    GCC provides __builtin___clear_cache which does should do syscall cacheflush. However it may have its caveats.

    Important thing here is Linux provides a system call (ARM specific) to flush caches. You can check Android/Bionic flushcache for how to use this system call. However I'm not sure what kind of guarantees Linux gives when you call it or how it is implemented through its inner workings.

    This blog post Caches and Self-Modifying Code may help further.

提交回复
热议问题