On 08/07/2013 02:24 PM, Brano Zarnovican wrote:
Hi,
I have an instance with 8G ram assigned. All block devices have cache
disabled (cache=none) on host. However, cgroup is reporting 4G of
cache associated to the instance (on host)
# cgget -r memory.stat libvirt/qemu/i-000009fa
libvirt/qemu/i-000009fa:
memory.stat: cache 4318011392
rss 8676360192
...
When I drop all system caches on host..
# echo 3 > /proc/sys/vm/drop_caches
#
..cache associated to the instance drops too.
# cgget -r memory.stat libvirt/qemu/i-000009fa
libvirt/qemu/i-000009fa:
memory.stat: cache 122880
rss 8674291712
...
Can somebody explain what is cached, if there is cache=none everywhere ?
At first let me explain that libvirt is not ignoring the cache=none.
This is propagated to qemu as a parameter for it's disk. From qemu's
POV (anyone feel free to correct me if I'm mistaken) this means the file
is opened with O_DIRECT flag; and from the open(2) manual, the O_DIRECT
means "Try to minimize cache effects of the I/O to and from this
file...", that doesn't necessarily mean there is no cache at all.
But even if it does, this applies to files used as disks, but those
disks are not the only files the process is using. You can check what
othe files the process has mapped, opened etc. from the '/proc'
filesystem or using the 'lsof' utility. All the other files can (and
probably will) take some cache and there is nothing wrong with that.
Are you trying to resolve an issue or asking just out of curiosity?
Because this is wanted behavior and there should be no need for anyone
to minimize this.
Have a nice day,
Martin