Skip to contentSkip to conversation

drop_caches ...

DISCUSSION Markus 5 participants 26 messages Mar 4, 2009 – Mar 5, 2009

Subsystems (10)
lore
Share & tools
lore

Markus

author
#0 lore raw

Hello!

I have a small problem. Maybe its just a misunderstanding but I cant solve it.

I think that writing "3" to drop_caches should drop all buffers and caches which are already written. So its recommended to put a "sync" infront of it.
So I did "free -m ; sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m" And it gave me:
total used free shared buffers
cached
Mem: 3950 3922 28 0 1
879
-/+ buffers/cache: 3041 909
Swap: 5342 205 5136
total used free shared buffers
cached
Mem: 3950 3907 43 0 0
864
-/+ buffers/cache: 3041 908
Swap: 5341 206 5135

So the buffer was 1 and is 0 afterthat. But cached is at 879 MB before and is still 864 MB (!!!) after that!

I am at swappiness=0 and when I remove and readd one swap-partition after another (so there is always swap). It will keep the cached and put the swapped memory on other swaps?!

I _think_ thats not the way it should go?

It would be really kind if someone could explain that issue and what "cached" is at all!

Have a nice day...
Markus

PS: Please CC me as I am not subscribed.

#1 lore raw

Hi Markus,

Quoted 26 lines · Markus

Hello!

I have a small problem. Maybe its just a misunderstanding but I cant solve it.

I think that writing "3" to drop_caches should drop all buffers and caches which are already written. So its recommended to put a "sync" infront of it.
So I did "free -m ; sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m" And it gave me:
total used free shared buffers
cached
Mem: 3950 3922 28 0 1
879
-/+ buffers/cache: 3041 909
Swap: 5342 205 5136
total used free shared buffers
cached
Mem: 3950 3907 43 0 0
864
-/+ buffers/cache: 3041 908
Swap: 5341 206 5135

So the buffer was 1 and is 0 afterthat. But cached is at 879 MB before and is still 864 MB (!!!) after that!

Quoted 8 lines

I am at swappiness=0 and when I remove and readd one swap-partition after another (so there is always swap). It will keep the cached and put the swapped memory on other swaps?!

I _think_ thats not the way it should go?

It would be really kind if someone could explain that issue and what "cached" is at all!

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

Thanks,
Fengguang

author
#2 lore raw

Hello Fengguang!

Quoted 12 lines

Hi Markus,

Quoted 9 lines · Markus

Hello!

I have a small problem. Maybe its just a misunderstanding but I cant solve it.

I think that writing "3" to drop_caches should drop all buffers and caches which are already written. So its recommended to put a "sync" infront of it.
So I did "free -m ; sync ; echo 3 > /proc/sys/vm/drop_caches ;

free -m"

Quoted 14 lines
Quoted 14 lines

And it gave me:
total used free shared buffers
cached
Mem: 3950 3922 28 0 1
879
-/+ buffers/cache: 3041 909
Swap: 5342 205 5136
total used free shared buffers
cached
Mem: 3950 3907 43 0 0
864
-/+ buffers/cache: 3041 908
Swap: 5341 206 5135

Quoted 1 line
Quoted 1 line

So the buffer was 1 and is 0 afterthat. But cached is at 879 MB

before

Quoted 6 lines
Quoted 6 lines

and is still 864 MB (!!!) after that!

I am at swappiness=0 and when I remove and readd one swap-partition after another (so there is always swap). It will keep the cached and put the swapped memory on other swaps?!

Quoted 7 lines
Quoted 4 lines

I _think_ thats not the way it should go?

It would be really kind if someone could explain that issue and what "cached" is at all!

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; cat /proc/meminfo
             total       used       free     shared    buffers     
cached
Mem:          3950       3262        688          0          0        
359
-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

thanks in advance

Markus

#3 lore raw
Quoted 86 lines · Markus

Hello Fengguang!

Quoted 12 lines

Hi Markus,

Quoted 9 lines · Markus

Hello!

I have a small problem. Maybe its just a misunderstanding but I cant solve it.

I think that writing "3" to drop_caches should drop all buffers and caches which are already written. So its recommended to put a "sync" infront of it.
So I did "free -m ; sync ; echo 3 > /proc/sys/vm/drop_caches ;

free -m"

Quoted 14 lines
Quoted 14 lines

And it gave me:
total used free shared buffers
cached
Mem: 3950 3922 28 0 1
879
-/+ buffers/cache: 3041 909
Swap: 5342 205 5136
total used free shared buffers
cached
Mem: 3950 3907 43 0 0
864
-/+ buffers/cache: 3041 908
Swap: 5341 206 5135

Quoted 1 line
Quoted 1 line

So the buffer was 1 and is 0 afterthat. But cached is at 879 MB

before

Quoted 6 lines
Quoted 6 lines

and is still 864 MB (!!!) after that!

I am at swappiness=0 and when I remove and readd one swap-partition after another (so there is always swap). It will keep the cached and put the swapped memory on other swaps?!

Quoted 7 lines
Quoted 4 lines

I _think_ thats not the way it should go?

It would be really kind if someone could explain that issue and what "cached" is at all!

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; cat /proc/meminfo
             total       used       free     shared    buffers     
cached
Mem:          3950       3262        688          0          0        
359
-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Thanks,
Fengguang

author
#4 lore raw
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 40 lines

total used free shared buffers
cached
Mem: 3950 3262 688 0 0
359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 5 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
# mount
/dev/md6 on / type ext3 (rw,noatime,nodiratime,barrier=0)
/proc on /proc type proc (rw,noexec,nosuid,noatime,nodiratime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
cachedir on /lib64/splash/cache type tmpfs (rw,size=4096k,mode=644)
/dev/md4 on /home type ext3 (rw,noatime,nodiratime,barrier=0)
/dev/md3 on /usr/portage type ext4 (rw,noatime,nodiratime,barrier=0)
shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs 
(rw,noexec,nosuid,devmode=0664,devgid=85)
automount(pid6507) on /mnt/.autofs/misc type autofs 
(rw,fd=4,pgrp=6507,minproto=2,maxproto=4)
automount(pid6521) on /mnt/.autofs/usb type autofs 
(rw,fd=4,pgrp=6521,minproto=2,maxproto=4)
/dev/md1 on /boot type ext2 (rw,noatime,nodiratime)

I dont know what exactly all that memory is used for. It varies from about 300 MB to up to one GB.
Tell me where to look and I will!

Thanks!

Markus

#5 lore raw
Quoted 81 lines · Markus
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 40 lines

total used free shared buffers
cached
Mem: 3950 3262 688 0 0
359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 5 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
# mount
/dev/md6 on / type ext3 (rw,noatime,nodiratime,barrier=0)
/proc on /proc type proc (rw,noexec,nosuid,noatime,nodiratime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
cachedir on /lib64/splash/cache type tmpfs (rw,size=4096k,mode=644)
/dev/md4 on /home type ext3 (rw,noatime,nodiratime,barrier=0)
/dev/md3 on /usr/portage type ext4 (rw,noatime,nodiratime,barrier=0)
shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs 
(rw,noexec,nosuid,devmode=0664,devgid=85)
automount(pid6507) on /mnt/.autofs/misc type autofs 
(rw,fd=4,pgrp=6507,minproto=2,maxproto=4)
automount(pid6521) on /mnt/.autofs/usb type autofs 
(rw,fd=4,pgrp=6521,minproto=2,maxproto=4)
/dev/md1 on /boot type ext2 (rw,noatime,nodiratime)
Quoted 3 lines

I dont know what exactly all that memory is used for. It varies from about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files. It's strange to me that there are so many undroppable cached pages(Cached=359M), and most of them lie out of the LRU queue(Active+Inactive file=53M)...

Anyone have better clues on these 'hidden' pages?

Thanks,
Fengguang

#6 lore raw

Wu Fengguang napsal(a):

Quoted 75 lines · Markus
Quoted 74 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 39 lines
Quoted 39 lines

total used free shared buffers
cached

Mem:          3950       3262        688          0          0        359
-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 4 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
# mount
/dev/md6 on / type ext3 (rw,noatime,nodiratime,barrier=0)
/proc on /proc type proc (rw,noexec,nosuid,noatime,nodiratime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
cachedir on /lib64/splash/cache type tmpfs (rw,size=4096k,mode=644)
/dev/md4 on /home type ext3 (rw,noatime,nodiratime,barrier=0)
/dev/md3 on /usr/portage type ext4 (rw,noatime,nodiratime,barrier=0)
shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)
automount(pid6507) on /mnt/.autofs/misc type autofs (rw,fd=4,pgrp=6507,minproto=2,maxproto=4)
automount(pid6521) on /mnt/.autofs/usb type autofs (rw,fd=4,pgrp=6521,minproto=2,maxproto=4)
/dev/md1 on /boot type ext2 (rw,noatime,nodiratime)
Quoted 8 lines
Quoted 2 lines

I dont know what exactly all that memory is used for. It varies from about 300 MB to up to one GB. Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files. It's strange to me that there are so many undroppable cached pages(Cached=359M), and most of them lie out of the LRU queue(Active+Inactive file=53M)...

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be close to your missing cached pages.

If you are using Intel GEM driver - there is some unlimited caching issue

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

Zdenek

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

author
#7 lore raw
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 40 lines

total used free shared buffers
cached
Mem: 3950 3262 688 0 0
359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 4 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
# mount
/dev/md6 on / type ext3 (rw,noatime,nodiratime,barrier=0)
/proc on /proc type proc (rw,noexec,nosuid,noatime,nodiratime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
cachedir on /lib64/splash/cache type tmpfs (rw,size=4096k,mode=644)
/dev/md4 on /home type ext3 (rw,noatime,nodiratime,barrier=0)
/dev/md3 on /usr/portage type ext4 

(rw,noatime,nodiratime,barrier=0)

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev) usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85) automount(pid6507) on /mnt/.autofs/misc type autofs (rw,fd=4,pgrp=6507,minproto=2,maxproto=4) automount(pid6521) on /mnt/.autofs/usb type autofs (rw,fd=4,pgrp=6521,minproto=2,maxproto=4) /dev/md1 on /boot type ext2 (rw,noatime,nodiratime)

I dont know what exactly all that memory is used for. It varies

from

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files.

It's

Quoted 1 line
Quoted 1 line

strange to me that there are so many undroppable cached

pages(Cached=359M),

Quoted 1 line
Quoted 1 line

and most of them lie out of the LRU queue(Active+Inactive

file=53M)...

Quoted 11 lines
Quoted 2 lines

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be close to

your

Quoted 4 lines

missing cached pages.

If you are using Intel GEM driver - there is some unlimited caching

issue

Quoted 3 lines

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

# cat /proc/`pidof X`/smaps | grep drm | wc -l
0
# cat /proc/dri/0/gem_objects
cat: /proc/dri/0/gem_objects: No such file or directory

I use Xorg 1.3 with an nvidia gpu. Dont know if I use a "Intel GEM driver".

Btw I am running a 2.6.28.2.

Thanks.
Markus

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

#8 lore raw

Markus napsal(a):

Quoted 100 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 39 lines
Quoted 39 lines

total used free shared buffers
cached

Mem:          3950       3262        688          0          0        359
-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 4 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
# mount
/dev/md6 on / type ext3 (rw,noatime,nodiratime,barrier=0)
/proc on /proc type proc (rw,noexec,nosuid,noatime,nodiratime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
cachedir on /lib64/splash/cache type tmpfs (rw,size=4096k,mode=644)
/dev/md4 on /home type ext3 (rw,noatime,nodiratime,barrier=0)
/dev/md3 on /usr/portage type ext4 

(rw,noatime,nodiratime,barrier=0)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85) automount(pid6507) on /mnt/.autofs/misc type autofs (rw,fd=4,pgrp=6507,minproto=2,maxproto=4) automount(pid6521) on /mnt/.autofs/usb type autofs (rw,fd=4,pgrp=6521,minproto=2,maxproto=4) /dev/md1 on /boot type ext2 (rw,noatime,nodiratime)

I dont know what exactly all that memory is used for. It varies

from

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files.

It's

Quoted 1 line
Quoted 1 line

strange to me that there are so many undroppable cached

pages(Cached=359M),

Quoted 1 line
Quoted 1 line

and most of them lie out of the LRU queue(Active+Inactive

file=53M)...

Quoted 9 lines
Quoted 1 line

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be close to

your

Quoted 4 lines

missing cached pages.

If you are using Intel GEM driver - there is some unlimited caching

issue

Quoted 9 lines
Quoted 2 lines

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

# cat /proc/`pidof X`/smaps | grep drm | wc -l
0
# cat /proc/dri/0/gem_objects
cat: /proc/dri/0/gem_objects: No such file or directory

I use Xorg 1.3 with an nvidia gpu. Dont know if I use a "Intel GEM driver".

Are you using binary driver from NVidia ?? Maybe you should ask authors of this binary blob ?

Could you try to use for a while Vesa driver to see, if you are able to get same strange results ?

Zdenek

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

author
#9 lore raw

Am Mittwoch, 4. März 2009 schrieb Zdenek Kabelac:

Quoted 80 lines

Markus napsal(a):

Quoted 79 lines
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 40 lines

total used free shared buffers
cached
Mem: 3950 3262 688 0 0
359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 4 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
Quoted 1 line
Quoted 1 line
Quoted 1 line

I dont know what exactly all that memory is used for. It varies

from

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files.

It's

Quoted 1 line
Quoted 1 line

strange to me that there are so many undroppable cached

pages(Cached=359M),

Quoted 1 line
Quoted 1 line

and most of them lie out of the LRU queue(Active+Inactive

file=53M)...

Quoted 9 lines
Quoted 1 line

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be close

to

Quoted 18 lines
Quoted 8 lines

your

Quoted 4 lines

missing cached pages.

If you are using Intel GEM driver - there is some unlimited caching

issue

Quoted 2 lines

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

Quoted 8 lines
# cat /proc/`pidof X`/smaps | grep drm | wc -l
0
# cat /proc/dri/0/gem_objects
cat: /proc/dri/0/gem_objects: No such file or directory

I use Xorg 1.3 with an nvidia gpu. Dont know if I use a "Intel GEM driver".

Quoted 4 lines

Are you using binary driver from NVidia ?? Maybe you should ask authors of this binary blob ?

Could you try to use for a while Vesa driver to see, if you are able

to get

Quoted 1 line

same strange results ?

I rebooted in console without the nvidia-module loaded and have the same results (updated to 2.6.28.7 btw):

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; cat /proc/meminfo
             total       used       free     shared    buffers     
cached
Mem:          3950       1647       2303          0          0        
924
-/+ buffers/cache:        722       3228
Swap:         5890          0       5890
MemTotal:        4045444 kB
MemFree:         2358944 kB
Buffers:             544 kB
Cached:           946624 kB
SwapCached:            0 kB
Active:          1614756 kB
Inactive:           7632 kB
Active(anon):    1602476 kB
Inactive(anon):        0 kB
Active(file):      12280 kB
Inactive(file):     7632 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        6032344 kB
Dirty:                72 kB
Writeback:            32 kB
AnonPages:        675224 kB
Mapped:            17756 kB
Slab:              19936 kB
SReclaimable:       9652 kB
SUnreclaim:        10284 kB
PageTables:         8296 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055064 kB
Committed_AS:    3648088 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       10616 kB
VmallocChunk:   34359716459 kB
DirectMap4k:        6080 kB
DirectMap2M:     4188160 kB

Thanks!
Markus

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

#10 lore raw
Quoted 137 lines · Markus

Am Mittwoch, 4. MA?rz 2009 schrieb Zdenek Kabelac:

Quoted 76 lines

Markus napsal(a):

Quoted 75 lines
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped pages.

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 40 lines

total used free shared buffers
cached
Mem: 3950 3262 688 0 0
359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB
Quoted 4 lines
Quoted 3 lines

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
/dev/md1               99M   19M   76M  20% /boot
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

I dont know what exactly all that memory is used for. It varies from about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs files.

It's strange to me that there are so many undroppable cached pages(Cached=359M), and most of them lie out of the LRU queue(Active+Inactive file=53M)...

Quoted 9 lines
Quoted 1 line

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be close

to

Quoted 18 lines
Quoted 8 lines

your

Quoted 4 lines

missing cached pages.

If you are using Intel GEM driver - there is some unlimited caching

issue

Quoted 2 lines

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

Quoted 8 lines
# cat /proc/`pidof X`/smaps | grep drm | wc -l
0
# cat /proc/dri/0/gem_objects
cat: /proc/dri/0/gem_objects: No such file or directory

I use Xorg 1.3 with an nvidia gpu. Dont know if I use a "Intel GEM driver".

Quoted 4 lines

Are you using binary driver from NVidia ?? Maybe you should ask authors of this binary blob ?

Could you try to use for a while Vesa driver to see, if you are able

to get

Quoted 1 line

same strange results ?

I rebooted in console without the nvidia-module loaded and have the same results (updated to 2.6.28.7 btw):

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; cat /proc/meminfo
             total       used       free     shared    buffers     
cached
Mem:          3950       1647       2303          0          0        
924
-/+ buffers/cache:        722       3228
Swap:         5890          0       5890
MemTotal:        4045444 kB
MemFree:         2358944 kB
Buffers:             544 kB
Cached:           946624 kB
SwapCached:            0 kB
Active:          1614756 kB
Inactive:           7632 kB
Active(anon):    1602476 kB
Inactive(anon):        0 kB
Active(file):      12280 kB
Inactive(file):     7632 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        6032344 kB
Dirty:                72 kB
Writeback:            32 kB
AnonPages:        675224 kB
Mapped:            17756 kB
Slab:              19936 kB
SReclaimable:       9652 kB
SUnreclaim:        10284 kB
PageTables:         8296 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
Quoted 8 lines
WritebackTmp:          0 kB
CommitLimit:     8055064 kB
Committed_AS:    3648088 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       10616 kB
VmallocChunk:   34359716459 kB
DirectMap4k:        6080 kB
DirectMap2M:     4188160 kB

Markus, you may want to try this patch, it will have better chance to figure out the hidden file pages.

1) apply the patch and recompile kernel with CONFIG_PROC_FILECACHE=m
2) after booting:
modprobe filecache
cp /proc/filecache filecache-date +'%F'
3) send us the copied file, it will list all cached files, including the normally hidden ones.

Thanks,
Fengguang

include/linux/mm.h +1 -0
@@ -27,6 +27,7 @@ extern unsigned long max_mapnr;
 extern unsigned long num_physpages;
 extern void * high_memory;
 extern int page_cluster;
+extern char * const zone_names[];
 
 #ifdef CONFIG_SYSCTL
 extern int sysctl_legacy_va_layout;
mm/page_alloc.c +1 -1
@@ -104,7 +104,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
 
 EXPORT_SYMBOL(totalram_pages);
 
-static char * const zone_names[MAX_NR_ZONES] = {
+char * const zone_names[MAX_NR_ZONES] = {
 #ifdef CONFIG_ZONE_DMA
 	 "DMA",
 #endif
fs/dcache.c +4 -1
@@ -1943,7 +1943,10 @@ char *__d_path(const struct path *path, 
 
 		if (dentry == root->dentry && vfsmnt == root->mnt)
 			break;
-		if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
+		if (unlikely(!vfsmnt)) {
+			if (IS_ROOT(dentry))
+				break;
+		} else if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
 			/* Global root? */
 			if (vfsmnt->mnt_parent == vfsmnt) {
 				goto global_root;
lib/radix-tree.c +0 -2
@@ -564,7 +564,6 @@ out:
 }
 EXPORT_SYMBOL(radix_tree_tag_clear);
 
-#ifndef __KERNEL__	/* Only the test harness uses this at present */
 /**
  * radix_tree_tag_get - get a tag on a radix tree node
  * @root:		radix tree root
@@ -627,7 +626,6 @@ int radix_tree_tag_get(struct radix_tree
 	}
 }
 EXPORT_SYMBOL(radix_tree_tag_get);
-#endif
 
 /**
  *	radix_tree_next_hole    -    find the next hole (not-present entry)
fs/inode.c +16 -0
@@ -82,6 +82,10 @@ static struct hlist_head *inode_hashtabl
  */
 DEFINE_SPINLOCK(inode_lock);
 
+EXPORT_SYMBOL(inode_in_use);
+EXPORT_SYMBOL(inode_unused);
+EXPORT_SYMBOL(inode_lock);
+
 /*
  * iprune_mutex provides exclusion between the kswapd or try_to_free_pages
  * icache shrinking path, and the umount path.  Without this exclusion,
@@ -247,6 +251,8 @@ void __iget(struct inode * inode)
 	inodes_stat.nr_unused--;
 }
 
+EXPORT_SYMBOL(__iget);
+
 /**
  * clear_inode - clear an inode
  * @inode: inode to clear
@@ -1353,6 +1359,16 @@ void inode_double_unlock(struct inode *i
 }
 EXPORT_SYMBOL(inode_double_unlock);
 
+
+struct hlist_head * get_inode_hash_budget(unsigned long index)
+{
+       if (index >= (1 << i_hash_shift))
+               return NULL;
+
+       return inode_hashtable + index;
+}
+EXPORT_SYMBOL_GPL(get_inode_hash_budget);
+
 static __initdata unsigned long ihash_entries;
 static int __init set_ihash_entries(char *str)
 {
fs/super.c +3 -0
@@ -45,6 +45,9 @@
 LIST_HEAD(super_blocks);
 DEFINE_SPINLOCK(sb_lock);
 
+EXPORT_SYMBOL(super_blocks);
+EXPORT_SYMBOL(sb_lock);
+
 /**
  *	alloc_super	-	create new superblock
  *	@type:	filesystem type superblock should belong to
mm/vmscan.c +1 -0
@@ -230,6 +230,7 @@ unsigned long shrink_slab(unsigned long 
 	up_read(&shrinker_rwsem);
 	return ret;
 }
+EXPORT_SYMBOL(shrink_slab);
 
 /* Called without lock on whether page is mapped, so answer is unstable */
 static inline int page_mapping_inuse(struct page *page)
mm/swap_state.c +1 -0
@@ -44,6 +44,7 @@ struct address_space swapper_space = {
 	.i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear),
 	.backing_dev_info = &swap_backing_dev_info,
 };
+EXPORT_SYMBOL_GPL(swapper_space);
 
 #define INC_CACHE_INFO(x)	do { swap_cache_info.x++; } while (0)
 
Documentation/filesystems/proc.txt +83 -0

95 lines not on this page · raw message

fs/proc/filecache.c new file +1035 -0

1,035 lines not on this page · raw message

fs/Kconfig +30 -0
@@ -750,6 +750,36 @@ config CONFIGFS_FS
 	  Both sysfs and configfs can and should exist together on the
 	  same system. One is not a replacement for the other.
 
+config PROC_FILECACHE
+	tristate "/proc/filecache support"
+	default m
+	depends on PROC_FS
+	help
+	  This option creates a file /proc/filecache which enables one to
+	  query/drop the cached files in memory.
+
+	  A quick start guide:
+
+	  # echo 'ls' > /proc/filecache
+	  # head /proc/filecache
+
+	  # echo 'cat /bin/bash' > /proc/filecache
+	  # head /proc/filecache
+
+	  # echo 'drop pagecache' > /proc/filecache
+	  # echo 'drop slabcache' > /proc/filecache
+
+	  For more details, please check Documentation/filesystems/proc.txt .
+
+	  It can be a handy tool for sysadms and desktop users.
+
+config PROC_FILECACHE_EXTRAS
+	bool "track extra states"
+	default y
+	depends on PROC_FILECACHE
+	help
+	  Track extra states that costs a little more time/space.
+
 endmenu
 
 menu "Miscellaneous filesystems"
fs/proc/Makefile +2 -1
@@ -2,7 +2,8 @@
 # Makefile for the Linux proc filesystem routines.
 #
 
-obj-$(CONFIG_PROC_FS) += proc.o
+obj-$(CONFIG_PROC_FS)		+= proc.o
+obj-$(CONFIG_PROC_FILECACHE)	+= filecache.o
 
 proc-y			:= nommu.o task_nommu.o
 proc-$(CONFIG_MMU)	:= mmu.o task_mmu.o
include/linux/fs.h +1 -0
@@ -1907,6 +1907,7 @@ extern void remove_inode_hash(struct ino
 static inline void insert_inode_hash(struct inode *inode) {
 	__insert_inode_hash(inode, inode->i_ino);
 }
+struct hlist_head * get_inode_hash_budget(unsigned long index);
 
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
#11 lore raw

Hello,

Quoted 2 lines · Wu Fengguang

Markus, you may want to try this patch, it will have better chance to figure out the hidden file pages.

just for curiosity, would it be possible to print process name which caused the file to be loaded into caches?

Signature · 7 lines
Luka1 Hejtmanek

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#12 lore raw
Quoted 8 lines

Hello,

Quoted 2 lines · Wu Fengguang

Markus, you may want to try this patch, it will have better chance to figure out the hidden file pages.

just for curiosity, would it be possible to print process name which caused the file to be loaded into caches?

impossible.
kernel don't know which process populate page cache.

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

#13 lore raw
Quoted 8 lines · KOSAKI Motohiro
Quoted 8 lines

Hello,

Quoted 2 lines · Wu Fengguang

Markus, you may want to try this patch, it will have better chance to figure out the hidden file pages.

just for curiosity, would it be possible to print process name which caused the file to be loaded into caches?

Yes the code has been there but not included in the patch I sent to you.

When enabled by the following option, the kernel will save the short name of current process into every _newly_ allocated inode structure, which will then be displayed in the filecache.

+config PROC_FILECACHE_EXTRAS

+       bool "track extra states"
+       default y
+       depends on PROC_FILECACHE
+       help

+ Track extra states that costs a little more time/space.

However it adds runtime overhead, and the information is not reliably usable. So not everyone will like this idea and I'm not maintaining this feature now.

But I do have an interesting old copy that shows the process names:

#      ino       size   cached cached% refcnt state accessed   uid process         dev          file
   1221729          1        4     100      0    --       27     0 rc              08:01(sda1)	/etc/default/rcS
   1058788         32       32     100      0    --       92     0 udevd           08:01(sda1)	/sbin/modprobe
   1221859          2        4     100      0    --        2     0 rc              08:01(sda1)	/etc/init.d/module-init-tools
   1400967          2        4     100      0    --       65     0 tput            08:01(sda1)	/lib/terminfo/l/linux
    195578         90       92     100      0    --       10     0 S03udev         08:01(sda1)	/usr/bin/expr
    196704         12       12     100      0    --       60     0 S03udev         08:01(sda1)	/usr/bin/tput
   1221849          1        4     100      0    --        2     0 S18ifupdown-cle 08:01(sda1)	/etc/default/ifupdown
   1221847          2        4     100      0    --        2     0 rc              08:01(sda1)	/etc/init.d/ifupdown-clean
   1726534          1        4     100      0    --       56     0 alsa-utils      08:01(sda1)	/bin/which
   1726549          7        8     100      0    --       25     0 sh              08:01(sda1)	/bin/mountpoint
   1221998          3        4     100      0    --       30     0 sh              08:01(sda1)	/etc/fstab
   1727533        100      100     100      0    --      306     0 sh              08:01(sda1)	/bin/grep
   1221653          3        4     100      0    --        3     0 rc              08:01(sda1)	/etc/init.d/mountdevsubfs.sh
   1400773          3        4     100      0    --        9     0 sh              08:01(sda1)	/lib/init/mount-functions.sh
   1400851          8        8     100      0    --       48     0 rc              08:01(sda1)	/lib/lsb/init-functions
   1727381         19       20     100      0    --       34     0 sh              08:01(sda1)	/bin/uname
   1221672          1        4     100      0    --        3     0 sh              08:01(sda1)	/etc/default/tmpfs
   1221669          1        4     100      0    --        3     0 sh              08:01(sda1)	/etc/default/devpts
   1224261          2        4     100      1    --      975     0 rcS             08:01(sda1)	/etc/passwd
   1221725          1        4     100      0    --      492     0 rcS             08:01(sda1)	/etc/nsswitch.conf
   1221659          4        4     100      0    --        1     0 rc              08:01(sda1)	/etc/init.d/mtab.sh
   1726557         50       52     100      0    --      186     0 rc              08:01(sda1)	/bin/sed
   1222991          2        4     100      0    --       25     0 mount           08:01(sda1)	/etc/blkid.tab
   1222681          1        4     100      0    --      207     0 init            08:01(sda1)	/etc/selinux/config
   1727379         40       40     100      0    --      251     0 sh              08:01(sda1)	/bin/rm
   1564027         35       36     100      9    --      142     0 touch           08:01(sda1)	/lib/librt-2.6.so
   1727368         40       40     100      0    --       70     0 sh              08:01(sda1)	/bin/touch
   1223550         97      100     100      0    --     4479     0 init            08:01(sda1)	/etc/ld.so.cache
   1400771         10       12     100      0    --        2     0 sh              08:01(sda1)	/lib/init/readlink
   1065053          8        8     100      0    --        2     0 sh              08:01(sda1)	/sbin/logsave
   1221665         10       12     100      0    --        1     0 rc              08:01(sda1)	/etc/init.d/checkroot.sh
     12661          1        4     100      1    d-       10     0 udevd           00:0e(tmpfs)	/.udev/db/block@sr0
     12320          1        4     100      1    D-       11     0 udevd           00:0e(tmpfs)	/.udev/db/md0
     12661          1        4     100      1    d-       10     0 udevd           00:0e(tmpfs)	/.udev/db/block@sr0
     12320          1        4     100      1    D-       11     0 udevd           00:0e(tmpfs)	/.udev/db/md0
     12316          1        4     100      1    D-       11     0 udevd           00:0e(tmpfs)	/.udev/db/md2
     12289          1        4     100      1    d-       10     0 udevd           00:0e(tmpfs)	/.udev/db/class@input@input2@event2
   1726532         19       20     100      0    --       42     0 net.agent       08:01(sda1)	/bin/sleep
     11918          1        4     100      1    d-       10     0 udevd           00:0e(tmpfs)	/.udev/db/class@input@input0@event0
     11912          1        4     100      1    d-       10     0 udevd           00:0e(tmpfs)	/.udev/db/class@input@input1@event1
   1058730         60       60     100      1    --        1     0 S03udev         08:01(sda1)	/sbin/udevd
   1564011        123      124     100     16    --      220     0 mount           08:01(sda1)	/lib/libpthread-2.6.so
   1400830         70       72     100      0    --       27     0 mount           08:01(sda1)	/lib/libdevmapper.so.1.02
   1400847         11       12     100      0    --       27     0 mount           08:01(sda1)	/lib/libuuid.so.1.2
   1400881         39       40     100      0    --       27     0 mount           08:01(sda1)	/lib/libblkid.so.1.0
   1726538         87       88     100      0    --       17     0 sh              08:01(sda1)	/bin/mount
   1221817          8        8     100      0    --        4     0 rcS             08:01(sda1)	/etc/init.d/rc
   1564018         43       44     100     50    --      492     0 rcS             08:01(sda1)	/lib/libnss_files-2.6.so
   1564012         43       44     100     43    --      473     0 rcS             08:01(sda1)	/lib/libnss_nis-2.6.so
   1564010         87       88     100     47    --      513     0 rcS             08:01(sda1)	/lib/libnsl-2.6.so
   1564020         35       36     100     43    --      473     0 rcS             08:01(sda1)	/lib/libnss_compat-2.6.so
   1661561        359      360     100     13    --      384     0 rcS             08:01(sda1)	/lib/libncurses.so.5.6
   1727359        752      752     100      2    --      291     0 init            08:01(sda1)	/bin/bash
   1564016         15       16     100     52    --      801     0 init            08:01(sda1)	/lib/libdl-2.6.so
   1564015       1352     1352     100     82    --     3338     0 init            08:01(sda1)	/lib/libc-2.6.so
   1402884         91       92     100      7    --      206     0 init            08:01(sda1)	/lib/libselinux.so.1
   1401085        236      236     100      7    --      206     0 init            08:01(sda1)	/lib/libsepol.so.1
   1564007        121      124     100     82    --     3338     0 run-init        08:01(sda1)	/lib/ld-2.6.so
   1058733         40       40     100      1    --        1     0 busybox         08:01(sda1)	/sbin/init
         0  160836480      308       0      0    --        0     0 mdadm           00:02(bdev)	(08:00)
         0   32226390        4       0      0    --        0     0 mdadm           00:02(bdev)	(08:02)
         0     128489        4       0      0    --        0     0 mdadm           00:02(bdev)	(08:07)
         0  160836480      308       0      0    --        0     0 mdadm           00:02(bdev)	(08:10)
         0   32226390        4       0      0    --        0     0 mdadm           00:02(bdev)	(08:12)
         0     313236        4       0      0    --        0     0 mdadm           00:02(bdev)	(08:18)
      7976          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda4
      7970          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda8
      7964          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb6
      7957          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda7
      7951          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda6
      7944          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb8
      7938          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb7
      7931          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda5
      7924          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb5
      7918          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda3
      7911          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb4
      7905          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb3
      7898          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda2
      7892          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda@sda1
      7885          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb2
      7851          1        4     100      1    D-       12     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb@sdb1
      7823          1        4     100      1    D-       32     0 udevd           00:0e(tmpfs)	/.udev/db/block@sda
      7769          1        4     100      1    D-       28     0 udevd           00:0e(tmpfs)	/.udev/db/block@sdb
      7472          1        4     100      1    D-        4     0 udevd           00:0e(tmpfs)	/.udev/db/class@input@input1@mouse0
      7068          1        4     100      1    D-        4     0 udevd           00:0e(tmpfs)	/.udev/db/class@input@mice
      2227          1        4     100      1    D-     1790     0 udevd           00:0e(tmpfs)	/.udev/uevent_seqnum
      2127          1        4     100      1    D-       11     0 init            00:0e(tmpfs)	/.initramfs/progress_state

Thanks,
Fengguang

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

author
#14 lore raw
In reply to Wu Fengguang

Am Donnerstag, 5. März 2009 schrieb Wu Fengguang:

Quoted 5 lines · Markus
Quoted 4 lines

Am Mittwoch, 4. März 2009 schrieb Zdenek Kabelac:

Quoted 3 lines

Markus napsal(a):

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The memory mapped pages won't be dropped in this way. "cat /proc/meminfo" will show you the number of mapped

pages.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 1 line
Quoted 1 line

total used free shared

buffers

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

cached
Mem: 3950 3262 688 0

0

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

359

-/+ buffers/cache:       2902       1047
Swap:         5890       1509       4381
MemTotal:        4045500 kB
MemFree:          705180 kB
Buffers:             508 kB
Cached:           367748 kB
SwapCached:       880744 kB
Active:          1555032 kB
Inactive:        1634868 kB
Active(anon):    1527100 kB
Inactive(anon):  1607328 kB
Active(file):      27932 kB
Inactive(file):    27540 kB
Unevictable:         816 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        4486496 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2378112 kB
Mapped:            52196 kB
Slab:              65640 kB
SReclaimable:      46192 kB
SUnreclaim:        19448 kB
PageTables:        28200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055092 kB
Committed_AS:    4915636 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       44580 kB
VmallocChunk:   34359677239 kB
DirectMap4k:     3182528 kB
DirectMap2M:     1011712 kB

The cached reduced to 359 MB (after the dropping). I dont know where to read the "number of mapped pages". "Mapped" is about 51 MB.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

Does your tmpfs store lots of files?

Dont think so:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  8.2G  5.6G  60% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   

3% /lib64/splash/cache

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
/dev/md4               19G   15G  3.1G  83% /home
/dev/md3              8.3G  4.5G  3.9G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm

/dev/md1 99M 19M 76M 20% /boot

I dont know what exactly all that memory is used for. It

varies

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

from about 300 MB to up to one GB.
Tell me where to look and I will!

So you don't have lots of mapped pages(Mapped=51M) or tmpfs

files.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

It's strange to me that there are so many undroppable cached

pages(Cached=359M),

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and most of them lie out of the LRU queue(Active+Inactive

file=53M)...

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

Anyone have better clues on these 'hidden' pages?

Maybe try this:

cat /proc/pidof X/smaps | grep drm | wc -l

you will see some growing numbers.

Also check cat /proc/dri/0/gem_objects
there should be some number # object bytes - which should be

close

Quoted 6 lines
Quoted 6 lines

to

Quoted 5 lines
Quoted 5 lines

your

Quoted 4 lines

missing cached pages.

If you are using Intel GEM driver - there is some unlimited

caching

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

issue

Quoted 2 lines

see: http://bugs.freedesktop.org/show_bug.cgi?id=20404

# cat /proc/`pidof X`/smaps | grep drm | wc -l
0
# cat /proc/dri/0/gem_objects
cat: /proc/dri/0/gem_objects: No such file or directory

I use Xorg 1.3 with an nvidia gpu. Dont know if I use a "Intel

GEM

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

driver".

Are you using binary driver from NVidia ?? Maybe you should ask authors of this binary blob ?

Could you try to use for a while Vesa driver to see, if you are

able

Quoted 4 lines
Quoted 4 lines

to get

Quoted 1 line

same strange results ?

I rebooted in console without the nvidia-module loaded and have the

same

Quoted 2 lines
Quoted 2 lines

results (updated to 2.6.28.7 btw):

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 

cat /proc/meminfo

Quoted 40 lines
Quoted 31 lines

total used free shared buffers
cached
Mem: 3950 1647 2303 0 0
924
-/+ buffers/cache: 722 3228

Swap:         5890          0       5890
MemTotal:        4045444 kB
MemFree:         2358944 kB
Buffers:             544 kB
Cached:           946624 kB
SwapCached:            0 kB
Active:          1614756 kB
Inactive:           7632 kB
Active(anon):    1602476 kB
Inactive(anon):        0 kB
Active(file):      12280 kB
Inactive(file):     7632 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        6032344 kB
Dirty:                72 kB
Writeback:            32 kB
AnonPages:        675224 kB
Mapped:            17756 kB
Slab:              19936 kB
SReclaimable:       9652 kB
SUnreclaim:        10284 kB
PageTables:         8296 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
Quoted 8 lines
WritebackTmp:          0 kB
CommitLimit:     8055064 kB
Committed_AS:    3648088 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       10616 kB
VmallocChunk:   34359716459 kB
DirectMap4k:        6080 kB
DirectMap2M:     4188160 kB
Quoted 1 line

Markus, you may want to try this patch, it will have better chance to

figure out

Quoted 8 lines

the hidden file pages.

1) apply the patch and recompile kernel with CONFIG_PROC_FILECACHE=m
2) after booting:
modprobe filecache
cp /proc/filecache filecache-date +'%F'
3) send us the copied file, it will list all cached files, including the normally hidden ones.

The file consists of 674 lines. If I interpret it right, "size" is the filesize and "cached" the amount of the file being in cache (why can this be bigger than the file?!).

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free -m ; 
cat /proc/meminfo ; cp /proc/filecache filecache-$(date +"%F")
             total       used       free     shared    buffers     
cached
Mem:          3950       1935       2015          0          0       
1009
-/+ buffers/cache:        925       3025
Swap:         5890          0       5890
MemTotal:        4045436 kB
MemFree:         2063976 kB
Buffers:             480 kB
Cached:          1033724 kB
SwapCached:            0 kB
Active:          1846000 kB
Inactive:          48552 kB
Active(anon):    1790892 kB
Inactive(anon):        8 kB
Active(file):      55108 kB
Inactive(file):    48544 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       6032344 kB
SwapFree:        6032344 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        860380 kB
Mapped:           101908 kB
Slab:              25772 kB
SReclaimable:      12560 kB
SUnreclaim:        13212 kB
PageTables:        16476 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8055060 kB
Committed_AS:    4132748 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       42256 kB
VmallocChunk:   34359683067 kB
DirectMap4k:       14272 kB
DirectMap2M:     4179968 kB
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and thats after a sync and a drop_caches! (Can be seen in the commands given.)

Thanks!
Markus

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

#15 lore raw

Hi Markus,

Could you please try the attached patch which will also show the user and process that opened these files? It adds three more fields when CONFIG_PROC_FILECACHE_EXTRAS is selected.

Thanks,
Fengguang

Quoted 13 lines · Markus
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
Quoted 6 lines

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and thats after a sync and a drop_caches! (Can be seen in the commands given.)

Thanks!
Markus

include/linux/mm.h +1 -0
@@ -27,6 +27,7 @@ extern unsigned long max_mapnr;
 extern unsigned long num_physpages;
 extern void * high_memory;
 extern int page_cluster;
+extern char * const zone_names[];
 
 #ifdef CONFIG_SYSCTL
 extern int sysctl_legacy_va_layout;
mm/page_alloc.c +1 -1
@@ -104,7 +104,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
 
 EXPORT_SYMBOL(totalram_pages);
 
-static char * const zone_names[MAX_NR_ZONES] = {
+char * const zone_names[MAX_NR_ZONES] = {
 #ifdef CONFIG_ZONE_DMA
 	 "DMA",
 #endif
fs/dcache.c +4 -1
@@ -1943,7 +1943,10 @@ char *__d_path(const struct path *path, 
 
 		if (dentry == root->dentry && vfsmnt == root->mnt)
 			break;
-		if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
+		if (unlikely(!vfsmnt)) {
+			if (IS_ROOT(dentry))
+				break;
+		} else if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
 			/* Global root? */
 			if (vfsmnt->mnt_parent == vfsmnt) {
 				goto global_root;
lib/radix-tree.c +0 -2
@@ -564,7 +564,6 @@ out:
 }
 EXPORT_SYMBOL(radix_tree_tag_clear);
 
-#ifndef __KERNEL__	/* Only the test harness uses this at present */
 /**
  * radix_tree_tag_get - get a tag on a radix tree node
  * @root:		radix tree root
@@ -627,7 +626,6 @@ int radix_tree_tag_get(struct radix_tree
 	}
 }
 EXPORT_SYMBOL(radix_tree_tag_get);
-#endif
 
 /**
  *	radix_tree_next_hole    -    find the next hole (not-present entry)
fs/inode.c +25 -0
@@ -82,6 +82,10 @@ static struct hlist_head *inode_hashtabl
  */
 DEFINE_SPINLOCK(inode_lock);
 
+EXPORT_SYMBOL(inode_in_use);
+EXPORT_SYMBOL(inode_unused);
+EXPORT_SYMBOL(inode_lock);
+
 /*
  * iprune_mutex provides exclusion between the kswapd or try_to_free_pages
  * icache shrinking path, and the umount path.  Without this exclusion,
@@ -108,6 +112,14 @@ static void wake_up_inode(struct inode *
 	wake_up_bit(&inode->i_state, __I_LOCK);
 }
 
+static inline void inode_created_by(struct inode *inode, struct task_struct *task)
+{
+#ifdef CONFIG_PROC_FILECACHE_EXTRAS
+	inode->i_cuid = task->uid;
+	memcpy(inode->i_comm, task->comm, sizeof(task->comm));
+#endif
+}
+
 static struct inode *alloc_inode(struct super_block *sb)
 {
 	static const struct address_space_operations empty_aops;
@@ -183,6 +195,7 @@ static struct inode *alloc_inode(struct 
 		}
 		inode->i_private = NULL;
 		inode->i_mapping = mapping;
+		inode_created_by(inode, current);
 	}
 	return inode;
 }
@@ -247,6 +260,8 @@ void __iget(struct inode * inode)
 	inodes_stat.nr_unused--;
 }
 
+EXPORT_SYMBOL(__iget);
+
 /**
  * clear_inode - clear an inode
  * @inode: inode to clear
@@ -1353,6 +1368,16 @@ void inode_double_unlock(struct inode *i
 }
 EXPORT_SYMBOL(inode_double_unlock);
 
+
+struct hlist_head * get_inode_hash_budget(unsigned long index)
+{
+       if (index >= (1 << i_hash_shift))
+               return NULL;
+
+       return inode_hashtable + index;
+}
+EXPORT_SYMBOL_GPL(get_inode_hash_budget);
+
 static __initdata unsigned long ihash_entries;
 static int __init set_ihash_entries(char *str)
 {
fs/super.c +3 -0
@@ -45,6 +45,9 @@
 LIST_HEAD(super_blocks);
 DEFINE_SPINLOCK(sb_lock);
 
+EXPORT_SYMBOL(super_blocks);
+EXPORT_SYMBOL(sb_lock);
+
 /**
  *	alloc_super	-	create new superblock
  *	@type:	filesystem type superblock should belong to
mm/vmscan.c +1 -0
@@ -230,6 +230,7 @@ unsigned long shrink_slab(unsigned long 
 	up_read(&shrinker_rwsem);
 	return ret;
 }
+EXPORT_SYMBOL(shrink_slab);
 
 /* Called without lock on whether page is mapped, so answer is unstable */
 static inline int page_mapping_inuse(struct page *page)
mm/swap_state.c +1 -0
@@ -44,6 +44,7 @@ struct address_space swapper_space = {
 	.i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear),
 	.backing_dev_info = &swap_backing_dev_info,
 };
+EXPORT_SYMBOL_GPL(swapper_space);
 
 #define INC_CACHE_INFO(x)	do { swap_cache_info.x++; } while (0)
 
Documentation/filesystems/proc.txt +83 -0

95 lines not on this page · raw message

fs/proc/filecache.c new file +1045 -0

1,045 lines not on this page · raw message

include/linux/fs.h +14 -0
@@ -685,6 +685,12 @@ struct inode {
 	void			*i_security;
 #endif
 	void			*i_private; /* fs or device private pointer */
+
+#ifdef CONFIG_PROC_FILECACHE_EXTRAS
+	unsigned int		i_access_count;	/* opened how many times? */
+	uid_t			i_cuid;		/* opened first by which user? */
+	char			i_comm[16];	/* opened first by which app? */
+#endif
 };
 
 /*
@@ -773,6 +779,13 @@ static inline unsigned imajor(const stru
 	return MAJOR(inode->i_rdev);
 }
 
+static inline void inode_accessed(struct inode *inode)
+{
+#ifdef CONFIG_PROC_FILECACHE_EXTRAS
+	inode->i_access_count++;
+#endif
+}
+
 extern struct block_device *I_BDEV(struct inode *inode);
 
 struct fown_struct {
@@ -1907,6 +1920,7 @@ extern void remove_inode_hash(struct ino
 static inline void insert_inode_hash(struct inode *inode) {
 	__insert_inode_hash(inode, inode->i_ino);
 }
+struct hlist_head * get_inode_hash_budget(unsigned long index);
 
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
fs/open.c +1 -0
@@ -828,6 +828,7 @@ static struct file *__dentry_open(struct
 			goto cleanup_all;
 	}
 
+	inode_accessed(inode);
 	f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
 
 	file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
fs/Kconfig +30 -0
@@ -750,6 +750,36 @@ config CONFIGFS_FS
 	  Both sysfs and configfs can and should exist together on the
 	  same system. One is not a replacement for the other.
 
+config PROC_FILECACHE
+	tristate "/proc/filecache support"
+	default m
+	depends on PROC_FS
+	help
+	  This option creates a file /proc/filecache which enables one to
+	  query/drop the cached files in memory.
+
+	  A quick start guide:
+
+	  # echo 'ls' > /proc/filecache
+	  # head /proc/filecache
+
+	  # echo 'cat /bin/bash' > /proc/filecache
+	  # head /proc/filecache
+
+	  # echo 'drop pagecache' > /proc/filecache
+	  # echo 'drop slabcache' > /proc/filecache
+
+	  For more details, please check Documentation/filesystems/proc.txt .
+
+	  It can be a handy tool for sysadms and desktop users.
+
+config PROC_FILECACHE_EXTRAS
+	bool "track extra states"
+	default y
+	depends on PROC_FILECACHE
+	help
+	  Track extra states that costs a little more time/space.
+
 endmenu
 
 menu "Miscellaneous filesystems"
fs/proc/Makefile +2 -1
@@ -2,7 +2,8 @@
 # Makefile for the Linux proc filesystem routines.
 #
 
-obj-$(CONFIG_PROC_FS) += proc.o
+obj-$(CONFIG_PROC_FS)		+= proc.o
+obj-$(CONFIG_PROC_FILECACHE)	+= filecache.o
 
 proc-y			:= nommu.o task_nommu.o
 proc-$(CONFIG_MMU)	:= mmu.o task_mmu.o
#20 lore raw
In reply to Markus

Hi Markus,

Quoted 10 lines · Markus
Quoted 9 lines

Markus, you may want to try this patch, it will have better chance to figure out the hidden file pages.

1) apply the patch and recompile kernel with CONFIG_PROC_FILECACHE=m
2) after booting:
modprobe filecache
cp /proc/filecache filecache-date +'%F'
3) send us the copied file, it will list all cached files, including the normally hidden ones.

Quoted 3 lines

The file consists of 674 lines. If I interpret it right, "size" is the filesize and "cached" the amount of the file being in cache (why can this be bigger than the file?!).

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

Thanks,
Fengguang

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

#21 lore raw
Quoted 4 lines · Wu Fengguang

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

I guess, the question was how it can happen that (cached > size).

Signature · 7 lines
Luka1 Hejtmanek

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#22 lore raw
Quoted 7 lines · Lukas Hejtmanek
Quoted 4 lines · Wu Fengguang

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

I guess, the question was how it can happen that (cached > size).

Ah, because cached size is rounded up to page boundaries, so a 1K sized file will have 4K cached size.

Thanks,
Fengguang

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

author
#23 lore raw
In reply to Wu Fengguang

Am Donnerstag, 5. März 2009 schrieb Wu Fengguang:

Quoted 4 lines

Hi Markus,

Quoted 1 line · Markus
Quoted 1 line

Markus, you may want to try this patch, it will have better chance

to figure out

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the hidden file pages.

1) apply the patch and recompile kernel with

CONFIG_PROC_FILECACHE=m

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

2) after booting:
modprobe filecache
cp /proc/filecache filecache-date +'%F'
3) send us the copied file, it will list all cached files,

including

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

the normally hidden ones.

The file consists of 674 lines. If I interpret it right, "size" is

the

Quoted 7 lines
Quoted 2 lines

filesize and "cached" the amount of the file being in cache (why can this be bigger than the file?!).

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

Yeah, I just wondered because sometimes its size < cached, buts thats because cached must obviously be a multiple of 4 KB. So no problem here ;)

Thanks,
Markus

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

#24 lore raw
In reply to Wu Fengguang
Quoted 7 lines · Wu Fengguang
Quoted 2 lines

filesize and "cached" the amount of the file being in cache (why can this be bigger than the file?!).

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

and one more thing. It seems that at least in the version of filecache I have, the size and cached are in kB rather than in B.

Signature · 7 lines
Luka1 Hejtmanek

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#16 lore raw
In reply to Wu Fengguang
Quoted 4 lines

Could you please try the attached patch which will also show the user and process that opened these files? It adds three more fields when CONFIG_PROC_FILECACHE_EXTRAS is selected.

Quoted 19 lines

Thanks,
Fengguang

Quoted 15 lines · Markus
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and

thats

Quoted 1 line
Quoted 1 line

after a sync and a drop_caches! (Can be seen in the commands given.)

I could, but I know where these things belong to. Its from sphinx (a mysql indexer) searchd. It loads parts of the index into memory. The sizes looked well-known and killing the searchd will reduce "cached" to a normal amount ;)

I just dont know why its in "cached" (can that be swapped out btw?). But I think thats not a problem of the kernel, but of anonymous mmap-ing.

I think its resolved, thanks to everybody and Fengguang in particular!

Markus

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

#25 lore raw
In reply to Lukas Hejtmanek
Quoted 11 lines · Lukas Hejtmanek
Quoted 7 lines · Wu Fengguang
Quoted 2 lines

filesize and "cached" the amount of the file being in cache (why can this be bigger than the file?!).

size = file size in bytes
cached = cached pages

So it's normal that (size > cached).

and one more thing. It seems that at least in the version of filecache I have, the size and cached are in kB rather than in B.

Ah sorry for the confusion, it is in KB: DIV_ROUND_UP(size, 1024). It may be better to simply use bytes though.

Thanks,
Fengguang

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

#17 lore raw
In reply to Markus

Hi Markus,

Quoted 23 lines · Markus
Quoted 4 lines

Could you please try the attached patch which will also show the user and process that opened these files? It adds three more fields when CONFIG_PROC_FILECACHE_EXTRAS is selected.

Quoted 19 lines

Thanks,
Fengguang

Quoted 15 lines · Markus
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and

Quoted 7 lines

thats

Quoted 1 line
Quoted 1 line

after a sync and a drop_caches! (Can be seen in the commands given.)

I could, but I know where these things belong to. Its from sphinx (a mysql indexer) searchd. It loads parts of the index into memory. The sizes looked well-known and killing the searchd will reduce "cached" to a normal amount ;)

And it's weird about the file name: /dev/zero. I wonder how it managed to create that file, and then delete it, inside a tmpfs!

Just out of curiosity, are they shm objects? Can you show us the output of 'df'? In your convenient time.

Quoted 3 lines

I just dont know why its in "cached" (can that be swapped out btw?). But I think thats not a problem of the kernel, but of anonymous mmap-ing.

You know, because the file is created in tmpfs, which is swap-backed. By definition the pages here cannot be dropped by third-party.

Quoted 1 line

I think its resolved, thanks to everybody and Fengguang in particular!

You are welcome :-)

Thanks,
Fengguang

author
#18 lore raw
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could you please try the attached patch which will also show the user and process that opened these files? It adds three more

fields

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

when CONFIG_PROC_FILECACHE_EXTRAS is selected.

Thanks,
Fengguang

Quoted 13 lines · Markus
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and

thats

Quoted 1 line
Quoted 1 line

after a sync and a drop_caches! (Can be seen in the commands

given.)

Quoted 4 lines
Quoted 4 lines

I could, but I know where these things belong to. Its from sphinx (a mysql indexer) searchd. It loads parts of the index into memory. The sizes looked well-known and killing the searchd will

reduce "cached"

Quoted 4 lines
Quoted 1 line

to a normal amount ;)

And it's weird about the file name: /dev/zero. I wonder how it managed to create that file, and then delete it, inside a tmpfs!

I dont know exactly. But in the source its just a:
... mmap ( NULL, m_iLength, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0 );
Perhaps thats the way shared anonymous memory is handled?!

Quoted 2 lines

Just out of curiosity, are they shm objects? Can you show us the output of 'df'? In your convenient time.

Thats all:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  7.9G  5.9G  58% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.2G  82% /home
/dev/md3              8.3G  4.5G  3.8G  55% /usr/portage
shm                   2.0G     0  2.0G   0% /dev/shm
Quoted 6 lines
Quoted 3 lines

I just dont know why its in "cached" (can that be swapped out btw?). But I think thats not a problem of the kernel, but of anonymous mmap-ing.

You know, because the file is created in tmpfs, which is swap-backed. By definition the pages here cannot be dropped by third-party.

Hm, ok.

Quoted 1 line
Quoted 1 line

I think its resolved, thanks to everybody and Fengguang in

particular!

Quoted 2 lines

You are welcome :-)

;)

Have a nice day.
Markus

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

#19 lore raw
Quoted 34 lines · Markus
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could you please try the attached patch which will also show the user and process that opened these files? It adds three more

fields

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

when CONFIG_PROC_FILECACHE_EXTRAS is selected.

Thanks,
Fengguang

Quoted 13 lines · Markus
# sort -n -k 3 filecache-2009-03-05 | tail -n 5
     15886       7112     7112     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16209      35708    35708     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     16212      82128    82128     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15887     340024   340024     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
     15884     455008   455008     100      1    d- 00:08
(tmpfs)        /dev/zero\040(deleted)
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

The sum of the third column is 1013 MB.
To note the biggest ones (or do you want the whole file?)... and

thats

Quoted 1 line
Quoted 1 line

after a sync and a drop_caches! (Can be seen in the commands

given.)

Quoted 4 lines
Quoted 4 lines

I could, but I know where these things belong to. Its from sphinx (a mysql indexer) searchd. It loads parts of the index into memory. The sizes looked well-known and killing the searchd will

reduce "cached"

Quoted 2 lines
Quoted 1 line

to a normal amount ;)

Quoted 7 lines
Quoted 2 lines

And it's weird about the file name: /dev/zero. I wonder how it managed to create that file, and then delete it, inside a tmpfs!

I dont know exactly. But in the source its just a:
... mmap ( NULL, m_iLength, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0 );
Perhaps thats the way shared anonymous memory is handled?!

Good to know this. The corresponding kernel function is:

        /**     
         * shmem_zero_setup - setup a shared anonymous mapping
         * @vma: the vma to be mmapped is prepared by do_mmap_pgoff
         */
        int shmem_zero_setup(struct vm_area_struct *vma)
        {       
                struct file *file;
                loff_t size = vma->vm_end - vma->vm_start;
                
                file = shmem_file_setup("dev/zero", size, vma->vm_flags);

Here goes the /dev/zero ^_^

Quoted 12 lines
Quoted 2 lines

Just out of curiosity, are they shm objects? Can you show us the output of 'df'? In your convenient time.

Thats all:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md6               14G  7.9G  5.9G  58% /
udev                   10M  304K  9.8M   3% /dev
cachedir              4.0M  100K  4.0M   3% /lib64/splash/cache
/dev/md4               19G   15G  3.2G  82% /home
/dev/md3              8.3G  4.5G  3.8G  55% /usr/portage
Quoted 1 line

shm 2.0G 0 2.0G 0% /dev/shm

shm objects will be accounted here. It's clean.

Thanks,
Fengguang

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