linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* SysV swapped shared memory calculated incorrectly
@ 2009-08-04 15:07 Niko Jokinen
  2009-08-05 18:21 ` Hugh Dickins
  0 siblings, 1 reply; 3+ messages in thread
From: Niko Jokinen @ 2009-08-04 15:07 UTC (permalink / raw)
  To: linux-mm

Hi,

Tested on 2.6.28 and 2.6.31-rc4

SysV swapped shared memory is not calculated correctly
in /proc/<pid>/smaps and also by parsing /proc/<pid>/pagemap.
Rss value decreases also when swap is disabled, so this is where I am
lost as how shared memory is supposed to behave.

I have test program which makes 32MB shared memory segment and then I
use 'stress -m 1 --vm-bytes 120M', --vm-bytes is increased until rss
size decreases in smaps. Swap value never increases in smaps.

On the other hand shmctl(0, SHM_INFO, ...) does show shared memory in
swap because shm.c shm_get_stat() uses inodes to get values.


When test program is started:

shmctl() printout:
SHM_INFO (sys-wide):       total : 34580 kB
                             rss : 34388 kB
                            swap : 192 kB

smaps printout:
40153000-42153000 rw-s 00000000 00:08 1703949    /SYSV54016264 (deleted)
Size:              32768 kB
Rss:               32768 kB
Pss:               32768 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:     32768 kB
Referenced:        32768 kB
Swap:                  0 kB

------------

After all memory is allocated (without swap smaps is the same, except
SHM_INFO shows 'Swap: 0' like it should), first byte is read hence the
4KB Referenced:

SHM_INFO (sys-wide):       total : 34580 kB
                             rss : 1528 kB
                            swap : 33052 kB


40153000-42153000 rw-s 00000000 00:08 1867789    /SYSV54016264 (deleted)
Size:              32768 kB
Rss:                   4 kB
Pss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         4 kB
Private_Dirty:         0 kB
Referenced:            4 kB
Swap:                  0 kB

------------

task_mmu.c, smaps_pte_range():

		if (is_swap_pte(ptent)) {
			mss->swap += PAGE_SIZE;
			continue;
		}

		if (!pte_present(ptent))
			continue;

When all memory is allocated pte_present() returns false for shared
memory. is_swap_pte() is never true for shared memory.

Ideas how to fix?


Br,
Niko Jokinen


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-07  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04 15:07 SysV swapped shared memory calculated incorrectly Niko Jokinen
2009-08-05 18:21 ` Hugh Dickins
2009-08-07  8:08   ` Niko Jokinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox