2009-03-04 09:57:46

by Markus

[permalink] [raw]
Subject: drop_caches ...

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.


2009-03-04 10:04:53

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

Hi Markus,

On Wed, Mar 04, 2009 at 10:57:33AM +0100, Markus wrote:
> 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!

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

Thanks,
Fengguang

2009-03-04 10:32:19

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

Hello Fengguang!

> Hi Markus,
>
> On Wed, Mar 04, 2009 at 10:57:33AM +0100, Markus wrote:
> > 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!
>
> 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

2009-03-04 11:11:24

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Wed, Mar 04, 2009 at 12:32:02PM +0200, Markus wrote:
> Hello Fengguang!
>
> > Hi Markus,
> >
> > On Wed, Mar 04, 2009 at 10:57:33AM +0100, Markus wrote:
> > > 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!
> >
> > 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.

Does your tmpfs store lots of files?

Thanks,
Fengguang

2009-03-04 11:29:59

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

> > > 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.
>
> 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

2009-03-04 11:57:58

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Wed, Mar 04, 2009 at 01:29:40PM +0200, Markus wrote:
> > > > 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.
> >
> > 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!

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

2009-03-04 12:32:54

by Zdenek Kabelac

[permalink] [raw]
Subject: Re: drop_caches ...

Wu Fengguang napsal(a):
> On Wed, Mar 04, 2009 at 01:29:40PM +0200, Markus wrote:
>>>>> 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.
>>> 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!
>
> 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





2009-03-04 12:38:40

by Lukas Hejtmanek

[permalink] [raw]
Subject: Re: drop_caches ...

Hello,

> 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?

I think he is simply using Intel driver + GEM + UXA = TONS of drm mm objects
in tmpfs which is 'hidden' unless you have /proc/filecache to see them.

--
Luk?? Hejtm?nek

2009-03-04 12:55:31

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Wed, Mar 04, 2009 at 02:38:36PM +0200, Lukas Hejtmanek wrote:
> Hello,
>
> > 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?
>
> I think he is simply using Intel driver + GEM + UXA = TONS of drm mm objects
> in tmpfs which is 'hidden' unless you have /proc/filecache to see them.

Ah I was about to ask him to try filecache before you and Zdenek kick in.

I was expecting the shm pages to be accounted in /dev/shm, however the
GEM shm pages are allocated from an in-kernel tmpfs mount...

And I noticed in filecache that you are compiling your own
/usr/local/drm/lib/libdrm_intel.so.1.0.0, now I know what are you doing ;-)

Good job, Lukas!

Thanks,
Fengguang

2009-03-04 13:48:09

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

> >>>>> 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.
> >>> 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!
> >
> > 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
>
# 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

2009-03-04 14:10:00

by Zdenek Kabelac

[permalink] [raw]
Subject: Re: drop_caches ...

Markus napsal(a):
>>>>>>> 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.
>>>>> 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!
>>> 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
>>
> # 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

2009-03-04 18:48:00

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

Am Mittwoch, 4. M?rz 2009 schrieb Zdenek Kabelac:
> Markus napsal(a):
> >>>>>>> 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.
> >>>>> 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
> >>>>
> >>>> 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
> >>
> > # 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 ?

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

2009-03-05 00:50:09

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Wed, Mar 04, 2009 at 08:47:41PM +0200, Markus wrote:
> Am Mittwoch, 4. März 2009 schrieb Zdenek Kabelac:
> > Markus napsal(a):
> > >>>>>>> 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.
> > >>>>> 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
> > >>>>
> > >>>> 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
> > >>
> > > # 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 ?
>
> 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

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


Attachments:
(No filename) (5.84 kB)
filecache-2.6.28.patch (31.24 kB)
Download all attachments

2009-03-05 09:06:44

by Lukas Hejtmanek

[permalink] [raw]
Subject: Re: drop_caches ...

Hello,

On Thu, Mar 05, 2009 at 08:48:50AM +0800, Wu Fengguang wrote:
> 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?

--
Luk?? Hejtm?nek

2009-03-05 09:14:53

by KOSAKI Motohiro

[permalink] [raw]
Subject: Re: drop_caches ...

> Hello,
>
> On Thu, Mar 05, 2009 at 08:48:50AM +0800, Wu Fengguang wrote:
> > 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.




2009-03-05 11:38:24

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 11:14:33AM +0200, KOSAKI Motohiro wrote:
> > Hello,
> >
> > On Thu, Mar 05, 2009 at 08:48:50AM +0800, Wu Fengguang wrote:
> > > 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

2009-03-05 11:55:59

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

Am Donnerstag, 5. M?rz 2009 schrieb Wu Fengguang:
> On Wed, Mar 04, 2009 at 08:47:41PM +0200, Markus wrote:
> > Am Mittwoch, 4. M?rz 2009 schrieb Zdenek Kabelac:
> > > Markus napsal(a):
> > > >>>>>>> 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.
> > > >>>>> 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
> > > >>>>
> > > >>>> 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
> > > >>
> > > > # 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 ?
> >
> > 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
>
> 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.

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

2009-03-05 13:30:37

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

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

On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
>
> # 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


Attachments:
(No filename) (1.01 kB)
filecache-2.6.28.patch (33.02 kB)
Download all attachments

2009-03-05 13:37:12

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

Hi Markus,

On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> > 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.
>
> 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

2009-03-05 13:45:47

by Lukas Hejtmanek

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 09:36:03PM +0800, Wu Fengguang wrote:
> 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).

--
Luk?? Hejtm?nek

2009-03-05 13:49:43

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 03:45:28PM +0200, Lukas Hejtmanek wrote:
> On Thu, Mar 05, 2009 at 09:36:03PM +0800, Wu Fengguang wrote:
> > 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

2009-03-05 13:50:38

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

Am Donnerstag, 5. M?rz 2009 schrieb Wu Fengguang:
> Hi Markus,
>
> On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> > > 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.
> >
> > 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).

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

2009-03-05 14:01:48

by Lukas Hejtmanek

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 09:36:03PM +0800, Wu Fengguang wrote:
> > 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.

--
Luk?? Hejtm?nek

2009-03-05 14:05:40

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

> 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
>
> On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> >
> > # 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.)

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

2009-03-05 14:08:19

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 04:01:25PM +0200, Lukas Hejtmanek wrote:
> On Thu, Mar 05, 2009 at 09:36:03PM +0800, Wu Fengguang wrote:
> > > 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

2009-03-05 14:23:40

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

Hi Markus,

On Thu, Mar 05, 2009 at 04:05:26PM +0200, Markus wrote:
> > 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
> >
> > On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> > >
> > > # 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.)
>
> 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.

> 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.

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

You are welcome :-)

Thanks,
Fengguang

2009-03-05 14:43:37

by Markus

[permalink] [raw]
Subject: Re: drop_caches ...

> > > 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
> > >
> > > On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> > > >
> > > > # 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.)
> >
> > 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!

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?!


> 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


> > 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.


> > I think its resolved, thanks to everybody and Fengguang in
particular!
>
> You are welcome :-)
;)

Have a nice day.
Markus

2009-03-05 14:54:00

by Fengguang Wu

[permalink] [raw]
Subject: Re: drop_caches ...

On Thu, Mar 05, 2009 at 04:43:22PM +0200, Markus wrote:
> > > > 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
> > > >
> > > > On Thu, Mar 05, 2009 at 01:55:35PM +0200, Markus wrote:
> > > > >
> > > > > # 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.)
> > >
> > > 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!
>
> 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 ^_^

> > 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

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

Thanks,
Fengguang