From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40471 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQyVU-0008QT-OF for qemu-devel@nongnu.org; Tue, 22 Jun 2010 04:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQyVR-0003b2-So for qemu-devel@nongnu.org; Tue, 22 Jun 2010 04:06:54 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:51978) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQyVR-0003aj-Ev for qemu-devel@nongnu.org; Tue, 22 Jun 2010 04:06:53 -0400 Message-ID: <4C206F1B.6080008@web.de> Date: Tue, 22 Jun 2010 10:06:51 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4C1BA0B4.2010803@siemens.com> <4C1BCEB0.6050601@codemonkey.ws> <20100621193123.GA14083@amt.cnet> <4C1FCABA.3060207@web.de> <4C1FD278.5040403@web.de> <20100621230607.GA19203@amt.cnet> In-Reply-To: <20100621230607.GA19203@amt.cnet> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD0DC1A10038EC8D73D73EF60" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] fix smp with tcg mode and --enable-io-thread List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: Glauber Costa , qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD0DC1A10038EC8D73D73EF60 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Marcelo Tosatti wrote: > On Mon, Jun 21, 2010 at 10:58:32PM +0200, Jan Kiszka wrote: >> Jan Kiszka wrote: >>> Marcelo Tosatti wrote: >>>> Clear exit_request when iothread grabs the global lock.=20 >>>> >>>> Signed-off-by: Marcelo Tosatti >>>> >>>> diff --git a/cpu-exec.c b/cpu-exec.c >>>> index 026980a..74cb973 100644 >>>> --- a/cpu-exec.c >>>> +++ b/cpu-exec.c >>>> @@ -236,10 +236,8 @@ int cpu_exec(CPUState *env1) >>>> asm(""); >>>> env =3D env1; >>>> =20 >>>> - if (exit_request) { >>>> + if (exit_request) >>>> env->exit_request =3D 1; >>>> - exit_request =3D 0; >>>> - } >>> Coding style... >>> >>>> =20 >>>> #if defined(TARGET_I386) >>>> if (!kvm_enabled()) { >>>> diff --git a/cpus.c b/cpus.c >>>> index fcd0f09..ef1ab22 100644 >>>> --- a/cpus.c >>>> +++ b/cpus.c >>>> @@ -598,6 +598,7 @@ void qemu_mutex_lock_iothread(void) >>>> } >>>> qemu_mutex_unlock(&qemu_fair_mutex); >>>> } >>>> + exit_request =3D 0; >>>> } >>>> =20 >>>> void qemu_mutex_unlock_iothread(void) >>>> >>>> >>> I looked into this a bit as well, and that's what I also have in my >>> queue. >>> >>> But things are still widely broken: pause_all_vcpus and run_on_cpu as= >>> there is no guarantee that all VCPUs regularly call into >>> qemu_wait_io_event. Also breakpoints don't work, not only in SMP mode= =2E >=20 > This fixes pause for me: >=20 Partially. It caused regressions on the SMP scheduling without the early loop exit in my patch. I will break up my changes later today and post them as series. >=20 > diff --git a/cpu-exec.c b/cpu-exec.c > index c776605..0149da5 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -238,7 +238,6 @@ int cpu_exec(CPUState *env1) > =20 > if (exit_request) { > env->exit_request =3D 1; > - exit_request =3D 0; > } > =20 > #if defined(TARGET_I386) > diff --git a/cpus.c b/cpus.c > index 826886c..14f7cfc 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -403,6 +403,8 @@ static void qemu_wait_io_event_common(CPUState *env= ) > =20 > static void qemu_wait_io_event(CPUState *env) > { > + CPUState *e; > + > while (!tcg_has_work()) > qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000);= > =20 > @@ -417,7 +419,9 @@ static void qemu_wait_io_event(CPUState *env) > qemu_mutex_unlock(&qemu_fair_mutex); > =20 > qemu_mutex_lock(&qemu_global_mutex); > - qemu_wait_io_event_common(env); > + > + for (e =3D first_cpu; e !=3D NULL; e =3D e->next_cpu) > + qemu_wait_io_event_common(e); > } > =20 > static void qemu_kvm_eat_signal(CPUState *env, int timeout) > @@ -614,6 +618,7 @@ void qemu_mutex_lock_iothread(void) > } > qemu_mutex_unlock(&qemu_fair_mutex); > } > + exit_request =3D 0; > } > =20 > void qemu_mutex_unlock_iothread(void) >=20 >=20 >=20 > Perhaps there is a similar problem with debugging (round robin=20 > in tcg_cpu_exec fails when there is a timer pending, and the=20 > iothread is not processing pending timers). >=20 Frankly, I still can't explain the round-robin logic. What complicates the situation is that it currently has to work in both threading modes. I really think we need a proper time-slicing model, maybe with early yield if the guest runs on some pause instruction, ie. spins on a lock. Jan --------------enigD0DC1A10038EC8D73D73EF60 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkwgbxsACgkQitSsb3rl5xSk8QCg2btA7G/TSEeJkBAuTBmlit2g yhgAoO/HYsej9KuX+4ZidNWq8SBC08GC =iA6c -----END PGP SIGNATURE----- --------------enigD0DC1A10038EC8D73D73EF60--