From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSxB-000844-RA for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:30:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCSx8-0007SU-A1 for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:30:29 -0400 Received: from greensocs.com ([193.104.36.180]:53485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSx7-0007S0-QS for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:30:26 -0400 Message-ID: <559BD46D.7060809@greensocs.com> Date: Tue, 07 Jul 2015 15:30:21 +0200 From: Frederic Konrad MIME-Version: 1.0 References: <1435330053-18733-1-git-send-email-fred.konrad@greensocs.com> <1435330053-18733-10-git-send-email-fred.konrad@greensocs.com> <87k2uc9k5n.fsf@linaro.org> In-Reply-To: <87k2uc9k5n.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH V6 09/18] cpu: add a tcg_executing flag. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QWxleCBCZW5uw6ll?= Cc: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, a.spyridakis@virtualopensystems.com, mark.burton@greensocs.com, agraf@suse.de, qemu-devel@nongnu.org, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, alistair.francis@xilinx.com On 07/07/2015 15:23, Alex Benn=C3=A9e wrote: > fred.konrad@greensocs.com writes: > >> From: KONRAD Frederic >> >> We need to know whether any other VCPU is executing code or not it's p= ossible >> with this flag. > Reword: "This flag indicates if the vCPU is currently executing TCG cod= e"? Ok >> Signed-off-by: KONRAD Frederic >> --- >> cpu-exec.c | 1 + >> cpus.c | 1 + >> include/qom/cpu.h | 3 +++ >> qom/cpu.c | 1 + >> 4 files changed, 6 insertions(+) >> >> diff --git a/cpu-exec.c b/cpu-exec.c >> index 0644383..de256d6 100644 >> --- a/cpu-exec.c >> +++ b/cpu-exec.c >> @@ -390,6 +390,7 @@ int cpu_exec(CPUArchState *env) >> cpu->halted =3D 0; >> } >> =20 >> + cpu->tcg_executing =3D 1; >> current_cpu =3D cpu; >> =20 >> rcu_read_lock(); >> diff --git a/cpus.c b/cpus.c >> index 2541c56..0291620 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -1377,6 +1377,7 @@ static int tcg_cpu_exec(CPUArchState *env) >> } >> qemu_mutex_unlock_iothread(); >> ret =3D cpu_exec(env); >> + cpu->tcg_executing =3D 0; > > This is an odd pairing, having the set in cpu_exec but the clear in the > outer call to it. Any particular reason it is unbalanced? true, no particular reason, I should move the clear in cpu_exec.. > >> qemu_mutex_lock_iothread(); >> #ifdef CONFIG_PROFILER >> tcg_time +=3D profile_getclock() - ti; >> diff --git a/include/qom/cpu.h b/include/qom/cpu.h >> index af3c9e4..1464afa 100644 >> --- a/include/qom/cpu.h >> +++ b/include/qom/cpu.h >> @@ -222,6 +222,7 @@ struct kvm_run; >> * @stopped: Indicates the CPU has been artificially stopped. >> * @tcg_exit_req: Set to force TCG to stop executing linked TBs for = this >> * CPU and return to its top level loop. >> + * @tcg_executing: This TCG thread is in cpu_exec(). >> * @singlestep_enabled: Flags for single-stepping. >> * @icount_extra: Instructions until next timer event. >> * @icount_decr: Number of cycles left, with interrupt flag in high = bit. >> @@ -315,6 +316,8 @@ struct CPUState { >> (absolute value) offset as small as possible. This reduces c= ode >> size, especially for hosts without large memory offsets. */ >> volatile sig_atomic_t tcg_exit_req; >> + >> + volatile int tcg_executing; >> }; >> =20 >> QTAILQ_HEAD(CPUTailQ, CPUState); >> diff --git a/qom/cpu.c b/qom/cpu.c >> index 108bfa2..ff41a4c 100644 >> --- a/qom/cpu.c >> +++ b/qom/cpu.c >> @@ -249,6 +249,7 @@ static void cpu_common_reset(CPUState *cpu) >> cpu->icount_decr.u32 =3D 0; >> cpu->can_do_io =3D 0; >> cpu->exception_index =3D -1; >> + cpu->tcg_executing =3D 0; >> memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *))= ; >> }