Search code examples
linuxmmapcpu-cache

Can memory from /dev/shm be cached in the CPU cache?


When memory is frequently accessed, it's put onto the CPU cache (L1, L2, L3). However, is the same true of memory that is mmap'd to a file living in /dev/shm? I ask because I wanted to know if having it backed to a file in /dev/shm would bypass any kind of caching by the CPU, and rather letting it fall through to a cache miss.


Solution

  • Yes they'll be cached in the core's L1/L2/L3 caches unless for instance the pages are marked uncached (e.g., by configuring the PAT accordingly) or the data is accessed via streaming reads/writes.