LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   SHM Memory Counted as Cache Memory with Kernel 2.6.18? (http://www.linuxquestions.org/questions/programming-9/shm-memory-counted-as-cache-memory-with-kernel-2-6-18-a-828505/)

kresyzig 08-25-2010 10:36 PM

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?

Kenny_Strawn 08-25-2010 11:06 PM

Try upgrading your kernel, maybe that will help. The 2.6.18 kernel is a full 18 point upgrades before the current one, at 2.6.36-rc2.

kresyzig 08-25-2010 11:35 PM

Quote:

Originally Posted by Kenny_Strawn (Post 4077921)
Try upgrading your kernel, maybe that will help. The 2.6.18 kernel is a full 18 point upgrades before the current one, at 2.6.36-rc2.

I wish it was an option but I am developing code to be run on standardized clusters running 2.6.18 ...

exvor 08-25-2010 11:54 PM

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.

kresyzig 08-26-2010 12:06 AM

Quote:

Originally Posted by exvor (Post 4077950)
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.


All times are GMT -5. The time now is 04:08 PM.