SHM Memory Counted as Cache Memory with Kernel 2.6.18?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
SHM Memory Counted as Cache Memory with Kernel 2.6.18?
Is that possible that SHM shared memory is counted as cache memory on Linux with kernel 2.6.18?
If find it really odd since this memory is not file backed, but I have a piece of code that loads data using shm_open+mmap, and it generates an amount of cache memory in /proc/meminfo that corresponds exactly to the amount of shared memory (I load that data from a file but I am using posix_fadvise(fd,0,0,POSIX_FADV_DONTNEED) to ensure this file is not cached and I made sure that it is working as expected). As far as I know SHM memory was not tagged as cache memory with kernel 2.6.9.
If it is the case it is really unfortunate since normally cache memory can be considered to be part of the "available" memory since it can be flushed promptly but this is clearly not the case with SHM memory... Is there an easy way to get the total amount of used SHM memory on a system?
As far as I know SHM memory is just a ram disk that the kernel uses for programs to communicate with each other. Thus it uses the same memory that the kernel uses for its caches. Other then that I do not think its any different then tempfs just uses a different name.
As far as I know SHM memory is just a ram disk that the kernel uses for programs to communicate with each other. Thus it uses the same memory that the kernel uses for its caches. Other then that I do not think its any different then tempfs just uses a different name.
But isn't cache memory by definition some memory used to reduce the access time to an original copy of some data? SHM memory just allows to share RAM between multiple processes, is neither file-backed nor involves multiple copies of the memory, so it is effectively not caching anything, right?
Quote:
A POSIX shared memory object is in effect a handle which can be used by unrelated processes to mmap(2) the same region of shared memory.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.