From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZu2o-0001aG-Pm for qemu-devel@nongnu.org; Mon, 23 Mar 2015 00:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZu2k-0006mV-M8 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 00:32:54 -0400 Received: from ozlabs.org ([103.22.144.67]:56425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZu2k-0006mI-4U for qemu-devel@nongnu.org; Mon, 23 Mar 2015 00:32:50 -0400 Date: Mon, 23 Mar 2015 15:32:09 +1100 From: David Gibson Message-ID: <20150323043209.GO25043@voom.fritz.box> References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-46-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="da9oBGf5DLtF9ehv" Content-Disposition: inline In-Reply-To: <1424883128-9841-46-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 45/45] Inhibit ballooning during postcopy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, qemu-devel@nongnu.org, amit.shah@redhat.com, pbonzini@redhat.com, yanghy@cn.fujitsu.com --da9oBGf5DLtF9ehv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 25, 2015 at 04:52:08PM +0000, Dr. David Alan Gilbert (git) wrot= e: > From: "Dr. David Alan Gilbert" >=20 > The userfault mechanism used for postcopy generates faults > for us on pages that are 'not present', inflating a balloon in > the guest causes host pages to be marked as 'not present'; doing > this during a postcopy, as potentially the same pages were being > received from the source, would confuse the state of the received > page -> disable ballooning during postcopy. That is a ludicrously long sentence, which I have great difficulty parsing. > When disabled we drop balloon requests from the guest. Since ballooning > is generally initiated by the host, the management system should avoid > initiating any balloon instructions to the guest during migration, > although it's not possible to know how long it would take a guest to > process a request made prior to the start of migration. Yeah :/. It would be nice if it could queue the guest actions, instead of dropping them. >=20 > Signed-off-by: Dr. David Alan Gilbert > --- > balloon.c | 11 +++++++++++ > hw/virtio/virtio-balloon.c | 4 +++- > include/sysemu/balloon.h | 2 ++ > migration/postcopy-ram.c | 9 +++++++++ > 4 files changed, 25 insertions(+), 1 deletion(-) >=20 > diff --git a/balloon.c b/balloon.c > index dea19a4..faedb60 100644 > --- a/balloon.c > +++ b/balloon.c > @@ -35,6 +35,17 @@ > static QEMUBalloonEvent *balloon_event_fn; > static QEMUBalloonStatus *balloon_stat_fn; > static void *balloon_opaque; > +static bool balloon_inhibited; > + > +bool qemu_balloon_is_inhibited(void) > +{ > + return balloon_inhibited; > +} > + > +void qemu_balloon_inhibit(bool state) > +{ > + balloon_inhibited =3D state; > +} > =20 > static bool have_ballon(Error **errp) > { > diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c > index 7bfbb75..b0e94ee 100644 > --- a/hw/virtio/virtio-balloon.c > +++ b/hw/virtio/virtio-balloon.c > @@ -36,9 +36,11 @@ > static void balloon_page(void *addr, int deflate) > { > #if defined(__linux__) > - if (!kvm_enabled() || kvm_has_sync_mmu()) > + if (!qemu_balloon_is_inhibited() && (!kvm_enabled() || > + kvm_has_sync_mmu())) { > qemu_madvise(addr, TARGET_PAGE_SIZE, > deflate ? QEMU_MADV_WILLNEED : QEMU_MADV_DONTNEED); > + } > #endif > } > =20 > diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h > index 0345e01..6851d99 100644 > --- a/include/sysemu/balloon.h > +++ b/include/sysemu/balloon.h > @@ -23,5 +23,7 @@ typedef void (QEMUBalloonStatus)(void *opaque, BalloonI= nfo *info); > int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, > QEMUBalloonStatus *stat_func, void *opaque); > void qemu_remove_balloon_handler(void *opaque); > +bool qemu_balloon_is_inhibited(void); > +void qemu_balloon_inhibit(bool state); > =20 > #endif > diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c > index d8f5ccd..b9f5848 100644 > --- a/migration/postcopy-ram.c > +++ b/migration/postcopy-ram.c > @@ -24,6 +24,7 @@ > #include "migration/migration.h" > #include "migration/postcopy-ram.h" > #include "sysemu/sysemu.h" > +#include "sysemu/balloon.h" > #include "qemu/bitmap.h" > #include "qemu/error-report.h" > #include "trace.h" > @@ -531,6 +532,8 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingSt= ate *mis) > mis->have_fault_thread =3D false; > } > =20 > + qemu_balloon_inhibit(false); > + > if (enable_mlock) { > if (os_mlock() < 0) { > error_report("mlock: %s", strerror(errno)); > @@ -780,6 +783,12 @@ int postcopy_ram_enable_notify(MigrationIncomingStat= e *mis) > return -1; > } > =20 > + /* > + * Ballooning can mark pages as absent while we're postcopying > + * that would cause false userfaults. > + */ > + qemu_balloon_inhibit(true); > + > trace_postcopy_ram_enable_notify(); > =20 > return 0; --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --da9oBGf5DLtF9ehv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVD5dJAAoJEGw4ysog2bOSvYYQAL2DJp5uF+MNAMg1sCJ22ztX O3ehI8+py/W4fOGm2u6PzCcIfk4S1LbYGH7hxwWbWMJmFi/11j+Kxkom1f0X8kzE wABotq+HR4TRLT2srNP3SHorSdWqGmNWT/p0s9+nP+p1wL9F2bWoe95zznQ16EdU y2Nzm3X5jBrH2yBwE0wGAEdpxG0O5eQqPN7KomBcOPp0LJ1/O2WdUJDBcresOVwT nuQxnxSpntK2yBg9foMS6LIK9kUeDLCdTFrPevVjT7nbbQjlP/ymb08jefkd4TWw lvr9a3CTYYg9CfRVFZseTXZ3Mr9CTSQyA3SJo2REso3qF0Jma0GZWFTD7KqzflVH 6HL0Yz7Q8CS76+DMbfAlCb0GyN9Nte1qR9Ofa+eovByvUpXqZW9m/LXKzGyLPZxJ RMNE8bscXmJTYdCmT4u5yBwsulNswPYlw9wLI2wpFXT14bKEiiAVdhoa99v+Ks8m X7kC15Zp2BkVO04+FUOtfxbRQSXJqVyIjjiH1Z9gv6uBN4mtKj+ZaJlUsPESQ8oS AxVhjfPr8V7AdLotwyOC99FsuGQpcscVFW96Yn9/lk8Uqh7PDHkNeLy0LALQUBM1 VJyuwIJfftEt+NuL48L4D4v+Fap9i1TiDSV3njhFnJYXQGqPNcaMvrHGkqd5+nGE FIkt3rrnPQvXIm5EPI/R =NZyI -----END PGP SIGNATURE----- --da9oBGf5DLtF9ehv--