From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2OdX-00015q-4r for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:25:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2OdV-00014h-IK for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:25:22 -0400 Received: from [199.232.76.173] (port=36522 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2OdV-00014W-Bp for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:25:21 -0400 Received: from narury.org ([84.20.150.76]:58969) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N2OdU-0003no-Lc for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:25:21 -0400 Date: Mon, 26 Oct 2009 14:25:16 +0200 From: Riku Voipio Subject: Re: [Qemu-devel] [Patch] Make usermode stacksize (-s) configurable at compile-time Message-ID: <20091026122516.GA15113@kos.to> References: <200910251622.07800.dl9pf@gmx.de> <761ea48b0910250854g2aa96a49w65eb5ede77c38f51@mail.gmail.com> <200910251841.25045.dl9pf@gmx.de> <200910251849.44301.dl9pf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <200910251849.44301.dl9pf@gmx.de> Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan-Simon =?utf-8?Q?M=C3=B6ller?= Cc: qemu-devel@nongnu.org On Sun, Oct 25, 2009 at 06:49:44PM +0100, Jan-Simon M=C3=B6ller wrote: > We encontered problems with the low default value for the stacksize in = usermode (ok, whats "low").=20 > For environments like scratchbox, its hard to use "-s" as qemu is calle= d by binfmt mechanism. > The attached patch makes this configurable at compile-time. fwiw in scratchbox we have a wrapper in between binfmt and qemu (called m= isc_runner) that sets any necessary command line parameters for qemu. You might want to consider a = similar approach so we don't need to add a configure option (and thus hardcode the setting) to q= emu for every command line option that might need changing. > Signed-off-by: Jan-Simon M=C3=B6ller >=20 > diff --git a/configure b/configure =20 > index 43d87c5..dad9175 100755 =20 > --- a/configure =20 > +++ b/configure =20 > @@ -220,6 +220,7 @@ uname_release=3D"" = =20 > io_thread=3D"no" = =20 > mixemu=3D"no" = =20 > kerneldir=3D"" = =20 > +user_mode_stacksize=3D"" = =20 > aix=3D"no" = =20 > blobs=3D"yes" = =20 > pkgversion=3D"" = =20 > @@ -557,6 +558,8 @@ for opt do =20 > ;; =20 > --kerneldir=3D*) kerneldir=3D"$optarg" = =20 > ;; =20 > + --user-mode-stacksize=3D*) user_mode_stacksize=3D"$optarg" = =20 > + ;; =20 > --with-pkgversion=3D*) pkgversion=3D" ($optarg)" = =20 > ;; =20 > --disable-docs) docs=3D"no" = =20 > @@ -713,6 +716,7 @@ echo " --enable-linux-aio enable Linux AIO s= upport" > echo " --enable-io-thread enable IO thread" > echo " --disable-blobs disable installing provided firmware = blobs" > echo " --kerneldir=3DPATH look for kernel includes in PATH" > +echo " --user-mode-stacksize=3D set default stack size in bytes (as= -s, only in usermode)" > echo "" > echo "NOTE: The object files are built at the place where configure is= launched" > exit 1 > @@ -2481,6 +2485,16 @@ if test "$target_user_only" =3D "yes" -a "$stati= c" =3D "no" -a \ > ldflags=3D"-pie $ldflags" > fi >=20 > +# change default stacksize in usermode > +# > +if test "$target_user_only" =3D "yes" -a "$user_mode_stacksize" !=3D "= " ; then > + cflags=3D"-DUSER_MODE_STACKSIZE=3D$user_mode_stacksize $cflags" > + echo "user_mode_stack $user_mode_stacksize" > +else > + echo "user_mode_stack default" > +fi > + > + > if test "$target_softmmu" =3D "yes" -a \( \ > "$TARGET_ARCH" =3D "microblaze" -o \ > "$TARGET_ARCH" =3D "cris" \) ; then > diff --git a/linux-user/main.c b/linux-user/main.c > index 81a1ada..9ac2421 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -51,7 +51,10 @@ const char *qemu_uname_release =3D CONFIG_UNAME_RELE= ASE; > /* XXX: on x86 MAP_GROWSDOWN only works if ESP <=3D address + 32, so > we allocate a bigger stack. Need a better solution, for example > by remapping the process stack directly at the right place */ > -unsigned long x86_stack_size =3D 512 * 1024; > +#ifndef USER_MODE_STACKSIZE > +#define USER_MODE_STACKSIZE (512 * 1024) > +#endif > +unsigned long x86_stack_size =3D USER_MODE_STACKSIZE; >=20 > void gemu_log(const char *fmt, ...) > { >=20 > diff --git a/configure b/configure > index 43d87c5..dad9175 100755 > --- a/configure > +++ b/configure > @@ -220,6 +220,7 @@ uname_release=3D"" > io_thread=3D"no" > mixemu=3D"no" > kerneldir=3D"" > +user_mode_stacksize=3D"" > aix=3D"no" > blobs=3D"yes" > pkgversion=3D"" > @@ -557,6 +558,8 @@ for opt do > ;; > --kerneldir=3D*) kerneldir=3D"$optarg" > ;; > + --user-mode-stacksize=3D*) user_mode_stacksize=3D"$optarg" > + ;; > --with-pkgversion=3D*) pkgversion=3D" ($optarg)" > ;; > --disable-docs) docs=3D"no" > @@ -713,6 +716,7 @@ echo " --enable-linux-aio enable Linux AIO s= upport" > echo " --enable-io-thread enable IO thread" > echo " --disable-blobs disable installing provided firmware = blobs" > echo " --kerneldir=3DPATH look for kernel includes in PATH" > +echo " --user-mode-stacksize=3D set default stack size in bytes (as= -s, only in usermode)" > echo "" > echo "NOTE: The object files are built at the place where configure is= launched" > exit 1 > @@ -2481,6 +2485,16 @@ if test "$target_user_only" =3D "yes" -a "$stati= c" =3D "no" -a \ > ldflags=3D"-pie $ldflags" > fi > =20 > +# change default stacksize in usermode > +# > +if test "$target_user_only" =3D "yes" -a "$user_mode_stacksize" !=3D "= " ; then > + cflags=3D"-DUSER_MODE_STACKSIZE=3D$user_mode_stacksize $cflags" > + echo "user_mode_stack $user_mode_stacksize" > +else > + echo "user_mode_stack default" > +fi > + > + > if test "$target_softmmu" =3D "yes" -a \( \ > "$TARGET_ARCH" =3D "microblaze" -o \ > "$TARGET_ARCH" =3D "cris" \) ; then > diff --git a/linux-user/main.c b/linux-user/main.c > index 81a1ada..9ac2421 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -51,7 +51,10 @@ const char *qemu_uname_release =3D CONFIG_UNAME_RELE= ASE; > /* XXX: on x86 MAP_GROWSDOWN only works if ESP <=3D address + 32, so > we allocate a bigger stack. Need a better solution, for example > by remapping the process stack directly at the right place */ > -unsigned long x86_stack_size =3D 512 * 1024; > +#ifndef USER_MODE_STACKSIZE > +#define USER_MODE_STACKSIZE (512 * 1024) > +#endif > +unsigned long x86_stack_size =3D USER_MODE_STACKSIZE; > =20 > void gemu_log(const char *fmt, ...) > {