Received: from eggs.gnu.org ([2001:4830:134:3::10]:46560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPN9n-0003Wl-Bq for qemu-devel@nongnu.org; Tue, 19 Jul 2016 01:01:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPN9i-0005z4-Aw for qemu-devel@nongnu.org; Tue, 19 Jul 2016 01:01:22 -0400 Date: Tue, 19 Jul 2016 13:34:00 +1000 From: David Gibson Message-ID: <20160719033400.GV16769@voom.fritz.box> References: <1468847944-24533-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Ln+iIw7POnzHEEo5" Content-Disposition: inline In-Reply-To: <1468847944-24533-1-git-send-email-thuth@redhat.com> Subject: Re: [Qemu-devel] [PATCH] ppc: Huge page detection mechanism fixes - Episode III List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Greg Kurz --Ln+iIw7POnzHEEo5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 18, 2016 at 03:19:04PM +0200, Thomas Huth wrote: > After already fixing two issues with the huge page detection mechanism > (see commit 159d2e39a860 and 86b50f2e1bef), Greg Kurz noticed another > case that caused the guest to crash where QEMU announces huge pages > though they should not be available for the guest: >=20 > qemu-system-ppc64 -enable-kvm ... -mem-path /dev/hugepages \ > -m 1G,slots=3D4,maxmem=3D32G > -object memory-backend-ram,policy=3Ddefault,size=3D1G,id=3Dmem-mem1 \ > -device pc-dimm,id=3Ddimm-mem1,memdev=3Dmem-mem1 -smp 2 \ > -numa node,nodeid=3D0 -numa node,nodeid=3D1 >=20 > That means if there is a global mem-path option, we still have > to look at the memory-backend objects that have been specified > additionally and return their minimum page size if that value > is smaller than the page size of the main memory. >=20 > Reported-by: Greg Kurz > Signed-off-by: Thomas Huth Applied to ppc-for-2.7, thanks. > --- > target-ppc/kvm.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) >=20 > diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c > index 7a8f555..97ab450 100644 > --- a/target-ppc/kvm.c > +++ b/target-ppc/kvm.c > @@ -366,10 +366,13 @@ static int find_max_supported_pagesize(Object *obj,= void *opaque) > static long getrampagesize(void) > { > long hpsize =3D LONG_MAX; > + long mainrampagesize; > Object *memdev_root; > =20 > if (mem_path) { > - return gethugepagesize(mem_path); > + mainrampagesize =3D gethugepagesize(mem_path); > + } else { > + mainrampagesize =3D getpagesize(); > } > =20 > /* it's possible we have memory-backend objects with > @@ -383,28 +386,26 @@ static long getrampagesize(void) > * backend isn't backed by hugepages. > */ > memdev_root =3D object_resolve_path("/objects", NULL); > - if (!memdev_root) { > - return getpagesize(); > + if (memdev_root) { > + object_child_foreach(memdev_root, find_max_supported_pagesize, &= hpsize); > } > - > - object_child_foreach(memdev_root, find_max_supported_pagesize, &hpsi= ze); > - > - if (hpsize =3D=3D LONG_MAX || hpsize =3D=3D getpagesize()) { > - return getpagesize(); > + if (hpsize =3D=3D LONG_MAX) { > + /* No additional memory regions found =3D=3D> Report main RAM pa= ge size */ > + return mainrampagesize; > } > =20 > /* If NUMA is disabled or the NUMA nodes are not backed with a > - * memory-backend, then there is at least one node using "normal" > - * RAM. And since normal RAM has not been configured with "-mem-path" > - * (what we've checked earlier here already), we can not use huge pa= ges! > + * memory-backend, then there is at least one node using "normal" RA= M, > + * so if its page size is smaller we have got to report that size in= stead. > */ > - if (nb_numa_nodes =3D=3D 0 || numa_info[0].node_memdev =3D=3D NULL) { > + if (hpsize > mainrampagesize && > + (nb_numa_nodes =3D=3D 0 || numa_info[0].node_memdev =3D=3D NULL)= ) { > static bool warned; > if (!warned) { > error_report("Huge page support disabled (n/a for main memor= y)."); > warned =3D true; > } > - return getpagesize(); > + return mainrampagesize; > } > =20 > return hpsize; --=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 --Ln+iIw7POnzHEEo5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXjZ+oAAoJEGw4ysog2bOS4ZIQAMXbkipi91wm1G24lDwsH2Pq e6DAwbToQ2GqOukUTgzKVzLymAhIxwIBhPxvYdq8V99Gp3yEeo4axc9vu3Nt3Ckx Rytw1i1hGMHV82LrSKW5/wLN0fj0DUG7EbXufu4U8I9Oq0NHGRyGYYChmUeXyjxz lzQV2JNjQ4lWOBhmlNeMO+6N9F3725CT/Rd1DgmJsJGkylrcwtPs1ucAZ3+miUDQ 87nqm1RPC8Vw7qIra6AP0PINfrtlKxFDRWEmu+CLxOPnb/JZSvaQ/HSEMzwNmb0e F7bgTjYBPg5e4/PGb/7aPe4MBnJZW9fCHYsB13Lm9qvujgFVCr/Nm8wlWJJgu5p5 44yhApytGFYRBPiKYwgpbsLqMjdCn8WocypAZXkQg3vVdkeNJSy6ejkq+AQgaPdH RuJCw1vqTuNLww4NJvKHZOnZQ+RF/L9pBIlMFZf1nRL5tLPm+BcQaULqONKqoruc 4K8JLXVIF7z/q15pqWkxPcGvOgFLX6JCZ37y0m8rCUk8jcSxjeovLor0VjfeyCg/ 5ICUuvachn3nvOSUmX/e55nY8DWVE4eVVEhcn4ogjuGVV37kf/qU/kq2IEi4vS1j LI5ocKhqQxgverYP8RKSnJOKQfm+3z2HxI9jkc2uocdk3AVuEqHfzB/SXD+PJmPN 6hDQPSQ07Rs571DvwOgO =tUME -----END PGP SIGNATURE----- --Ln+iIw7POnzHEEo5--