qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Liang Li <liang.z.li@intel.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, quintela@redhat.com,
	mst@redhat.com, dgilbert@redhat.com, lcapitulino@redhat.com,
	amit.shah@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache
Date: Mon, 13 Jun 2016 11:50:08 +0100	[thread overview]
Message-ID: <20160613105008.GJ18794@redhat.com> (raw)
In-Reply-To: <1465813009-21390-4-git-send-email-liang.z.li@intel.com>

On Mon, Jun 13, 2016 at 06:16:45PM +0800, Liang Li wrote:
> Add the hmp and qmp interface to drop vm's page cache, users
> can control the type of cache they want vm to drop.
> 
> Signed-off-by: Liang Li <liang.z.li@intel.com>
> ---
>  balloon.c        | 19 +++++++++++++++++++
>  hmp-commands.hx  | 15 +++++++++++++++
>  hmp.c            | 22 ++++++++++++++++++++++
>  hmp.h            |  3 +++
>  monitor.c        | 18 ++++++++++++++++++
>  qapi-schema.json | 35 +++++++++++++++++++++++++++++++++++
>  qmp-commands.hx  | 23 +++++++++++++++++++++++
>  7 files changed, 135 insertions(+)

> diff --git a/qapi-schema.json b/qapi-schema.json
> index 8483bdf..117f70a 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -1655,6 +1655,41 @@
>  { 'command': 'balloon', 'data': {'value': 'int'} }
>  
>  ##
> +# @DropCacheType
> +#
> +# Cache types enumeration
> +#
> +# @clean: Drop the clean page cache.
> +#
> +# @slab: Drop the slab cache.
> +#
> +# @all: Drop both the clean and the slab cache.
> +#
> +# Since: 2.7
> +##
> +{ 'enum': 'DropCacheType', 'data': ['clean', 'slab', 'all'] }

Presumably these constants are corresponding to the 3 options
for vm.drop_caches sysctl knob

[quote]
To free pagecache, use:

  echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes, use:

  echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes, use:

  echo 3 > /proc/sys/vm/drop_caches

Because writing to this file is a nondestructive
operation and dirty objects are not freeable, the
user should run sync(1) first.
[/quote]

IOW, by 'slab' you mean dentries and inodes ?

> +
> +##
> +# @balloon_drop_cache:
> +#
> +# Request the vm to drop its cache.
> +#
> +# @value: the type of cache want vm to drop
> +#
> +# Returns: Nothing on success
> +#          If the balloon driver is enabled but not functional because the KVM
> +#            kernel module cannot support it, KvmMissingCap
> +#          If no balloon device is present, DeviceNotActive
> +#
> +# Notes: This command just issues a request to the guest.  When it returns,
> +#        the drop cache operation may not have completed.  A guest can drop its
> +#        cache independent of this command.
> +#
> +# Since: 2.7.0
> +##
> +{ 'command': 'balloon_drop_cache', 'data': {'value': 'DropCacheType'} }

Also, as noted in the man page quote above, it is recommended to call
sync() to minimise dirty pages. Should we have a way to request a sync
as part of this monitor command.

More generally, it feels like this is taking as down a path towards
actively managing the guest kernel VM from the host. Is this really
a path we want to be going down, given that its going to take us into
increasing non-portable concepts which are potentially different for
each guest OS kernel.  Is this drop caches feature at all applicable
to Windows, OS-X, *BSD guest OS impls of the balloon driver ? If it
is applicable, are the 3 fixed constants you've defined at all useful
to those other OS ?

I'm warying of us taking a design path which is so Linux specific it
isn't useful elsewhere. IOW, just because we can do this, doesn't mean
we should do this...

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-06-13 10:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-13 10:16 [Qemu-devel] [QEMU 0/7] Fast balloon and fast live migration Liang Li
2016-06-13 10:16 ` [Qemu-devel] [QEMU 1/7] balloon: speed up inflating & deflating process Liang Li
2016-06-14 11:37   ` Thomas Huth
2016-06-14 14:22     ` Li, Liang Z
2016-06-14 14:41       ` Li, Liang Z
2016-06-14 15:33         ` Thomas Huth
2016-06-17  0:54           ` Li, Liang Z
2016-06-19  4:12   ` Michael S. Tsirkin
2016-06-20  1:37     ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 2/7] virtio-balloon: add drop cache support Liang Li
2016-06-19  4:14   ` Michael S. Tsirkin
2016-06-20  2:09     ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 3/7] Add the hmp and qmp interface for dropping cache Liang Li
2016-06-13 10:50   ` Daniel P. Berrange [this message]
2016-06-13 11:06     ` Daniel P. Berrange
2016-06-13 14:12       ` Li, Liang Z
2016-06-13 11:41     ` Paolo Bonzini
2016-06-13 14:14       ` Li, Liang Z
2016-06-13 13:50     ` Li, Liang Z
2016-06-13 15:09       ` Dr. David Alan Gilbert
2016-06-14  1:15         ` Li, Liang Z
2016-06-17  1:35         ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 4/7] balloon: get free page info from guest Liang Li
2016-06-19  4:24   ` Michael S. Tsirkin
2016-06-20  2:48     ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 5/7] bitmap: Add a new bitmap_move function Liang Li
2016-06-13 10:16 ` [Qemu-devel] [QEMU 6/7] kvm: Add two new arch specific functions Liang Li
2016-06-19  4:27   ` Michael S. Tsirkin
2016-06-20  3:16     ` Li, Liang Z
2016-06-13 10:16 ` [Qemu-devel] [QEMU 7/7] migration: skip free pages during live migration Liang Li
2016-06-19  4:43   ` Michael S. Tsirkin
2016-06-20  2:52     ` Li, Liang Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160613105008.GJ18794@redhat.com \
    --to=berrange@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lcapitulino@redhat.com \
    --cc=liang.z.li@intel.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).