From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asMro-0003Ic-8z for qemu-devel@nongnu.org; Tue, 19 Apr 2016 00:02:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asMrj-00010o-6k for qemu-devel@nongnu.org; Tue, 19 Apr 2016 00:02:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asMrj-00010D-0Y for qemu-devel@nongnu.org; Tue, 19 Apr 2016 00:02:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F334692476 for ; Tue, 19 Apr 2016 04:02:17 +0000 (UTC) Date: Tue, 19 Apr 2016 14:03:32 +1000 From: David Gibson Message-ID: <20160419140332.0cf97ec1@voom.fritz.box> In-Reply-To: <1460623807-12654-1-git-send-email-thuth@redhat.com> References: <1460623807-12654-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/OM8_9.RFmtefbMxs5.X=AJ2"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [PATCH] hw/virtio/balloon: Replace TARGET_PAGE_SIZE with BALLOON_PAGE_SIZE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, dgilbert@redhat.com, wehuang@redhat.com, drjones@redhat.com --Sig_/OM8_9.RFmtefbMxs5.X=AJ2 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 14 Apr 2016 10:50:07 +0200 Thomas Huth wrote: > The balloon code currently calls madvise() with TARGET_PAGE_SIZE as > length parameter. Since the virtio-balloon protocol is always based > on 4k pages, no matter what the host and guest are using as page size, > this could cause problems: If TARGET_PAGE_SIZE is bigger than 4k, the > madvise call also destroys the 4k areas after the current one - which > might be wrong since the guest did not want free that area yet (in > case the guest used as smaller MMU page size than the hard-coded > TARGET_PAGE_SIZE). So to fix this issue, introduce a proper define > called BALLOON_PAGE_SIZE (which is 4096) to use this as the size > parameter for the madvise() call instead. >=20 > Signed-off-by: Thomas Huth Reviewed-by: David Gibson > --- > hw/virtio/virtio-balloon.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c > index c74101e..9dbe681 100644 > --- a/hw/virtio/virtio-balloon.c > +++ b/hw/virtio/virtio-balloon.c > @@ -19,7 +19,6 @@ > #include "qemu-common.h" > #include "hw/virtio/virtio.h" > #include "hw/i386/pc.h" > -#include "cpu.h" > #include "sysemu/balloon.h" > #include "hw/virtio/virtio-balloon.h" > #include "sysemu/kvm.h" > @@ -35,12 +34,14 @@ > #include "hw/virtio/virtio-bus.h" > #include "hw/virtio/virtio-access.h" > =20 > +#define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) > + > static void balloon_page(void *addr, int deflate) > { > #if defined(__linux__) > if (!qemu_balloon_is_inhibited() && (!kvm_enabled() || > kvm_has_sync_mmu())) { > - qemu_madvise(addr, TARGET_PAGE_SIZE, > + qemu_madvise(addr, BALLOON_PAGE_SIZE, > deflate ? QEMU_MADV_WILLNEED : QEMU_MADV_DONTNEED); > } > #endif > --=20 > 1.8.3.1 >=20 --=20 David Gibson Senior Software Engineer, Virtualization, Red Hat --Sig_/OM8_9.RFmtefbMxs5.X=AJ2 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXFa4UAAoJEGw4ysog2bOS3W0P/jvbJc05FKPlBpuJFt7dDoxB yIOD6C8MkGbIfGVydwpLzTVBsJU9ksLcfFLUbpm3xz1LcLA8X3K+Qo/P3WAUdzOz qJOWaEFuBpX8mLBTfhp4s3xqThBxucTricHmWMWz98wULa79ZUKC4lH8P7REK8bh Q/pNKf5IIn4Y0si33DWNRLiwqdjZlVXScROx+XRcBgg/bKO5lB/N/QZwKIgpCNn7 suM7IPDTW2JjV0GWcptoKoxRYI+9FJOU1dMrvBMSWhMlGxpV3dP0mRiYnSPKe/Qv Mk72ejXlJdsbuYzHSaSAxfnNCroATmKfBZqBTv14hu/8B5r4SOIlpZ/pZkRiAemY SyA1sVEKJR5CfMj3Jv0KH4mHZMzJsr5n8Z6/RwTsTA4BkEpPI4QhCd8JLTqlE3m2 h8scYdqsUxsTGRI7X/4Nz6qPDPjbPO7s62F/Lz5gQR7y9zCN65Ps37J82OK/ETOg 8xeY5oI5ZQ1O1B59HmsMtW+jP2BW6Qy29VKv9cHY+HVqYPSDcoPwdvTVjUk0qlMG o0vecIaYLukzcmExPfmGUjybJXLvs9WDla8B7ct6sjxz2yxlAUhin/wlBtjqfL2a mSJgSr7RXfeOR8XWosniC9Yaqa7Rw5VLjKObtpA3LyK/3wcYpxszIWTSoAxvUjpM 2GUXOafNf3Q53CdGBabz =B9qX -----END PGP SIGNATURE----- --Sig_/OM8_9.RFmtefbMxs5.X=AJ2--