* [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception
@ 2016-11-02 14:25 Pranith Kumar
2016-11-02 16:22 ` Alex Bennée
2016-11-02 16:40 ` [Qemu-devel] [PATCH v2] " Pranith Kumar
0 siblings, 2 replies; 6+ messages in thread
From: Pranith Kumar @ 2016-11-02 14:25 UTC (permalink / raw)
To: qemu-devel, alex.bennee; +Cc: pbonzini
The patch enables handling atomic code in the guest. This should be
preferably done in cpu_handle_exception(), but the current assumptions
regarding when we can execute atomic sections cause a deadlock.
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
cpus.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/cpus.c b/cpus.c
index 8f98060..c4ba7d8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1315,6 +1315,9 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
break;
+ } else if (r == EXCP_ATOMIC) {
+ cpu_exec_step_atomic(cpu);
+ break;
}
} else if (cpu->stop) {
if (cpu->unplug) {
@@ -1385,6 +1388,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
*/
g_assert(cpu->halted);
break;
+ case EXCP_ATOMIC:
+ qemu_mutex_unlock_iothread();
+ cpu_exec_step_atomic(cpu);
+ qemu_mutex_lock_iothread();
default:
/* Ignore everything else? */
break;
--
2.10.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception
2016-11-02 14:25 [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception Pranith Kumar
@ 2016-11-02 16:22 ` Alex Bennée
2016-11-02 16:30 ` Pranith Kumar
2016-11-02 16:40 ` [Qemu-devel] [PATCH v2] " Pranith Kumar
1 sibling, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2016-11-02 16:22 UTC (permalink / raw)
To: Pranith Kumar; +Cc: qemu-devel, pbonzini
Pranith Kumar <bobby.prani@gmail.com> writes:
> The patch enables handling atomic code in the guest. This should be
> preferably done in cpu_handle_exception(), but the current assumptions
> regarding when we can execute atomic sections cause a deadlock.
>
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
> cpus.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/cpus.c b/cpus.c
> index 8f98060..c4ba7d8 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1315,6 +1315,9 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
> if (r == EXCP_DEBUG) {
> cpu_handle_guest_debug(cpu);
> break;
> + } else if (r == EXCP_ATOMIC) {
> + cpu_exec_step_atomic(cpu);
> + break;
Hmm don't we need to unlock the iothread here as well? I suspect you
never see a deadlock because the rr thread can't by definition race with
itself but the locking practice should be the same for both cases.
> }
> } else if (cpu->stop) {
> if (cpu->unplug) {
> @@ -1385,6 +1388,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
> */
> g_assert(cpu->halted);
> break;
> + case EXCP_ATOMIC:
> + qemu_mutex_unlock_iothread();
> + cpu_exec_step_atomic(cpu);
> + qemu_mutex_lock_iothread();
> default:
> /* Ignore everything else? */
> break;
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception
2016-11-02 16:22 ` Alex Bennée
@ 2016-11-02 16:30 ` Pranith Kumar
0 siblings, 0 replies; 6+ messages in thread
From: Pranith Kumar @ 2016-11-02 16:30 UTC (permalink / raw)
To: Alex Bennée; +Cc: qemu-devel, pbonzini
Alex Bennée writes:
> Pranith Kumar <bobby.prani@gmail.com> writes:
>
>> The patch enables handling atomic code in the guest. This should be
>> preferably done in cpu_handle_exception(), but the current assumptions
>> regarding when we can execute atomic sections cause a deadlock.
>>
>> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
>> ---
>> cpus.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/cpus.c b/cpus.c
>> index 8f98060..c4ba7d8 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -1315,6 +1315,9 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
>> if (r == EXCP_DEBUG) {
>> cpu_handle_guest_debug(cpu);
>> break;
>> + } else if (r == EXCP_ATOMIC) {
>> + cpu_exec_step_atomic(cpu);
>> + break;
>
> Hmm don't we need to unlock the iothread here as well? I suspect you
> never see a deadlock because the rr thread can't by definition race with
> itself but the locking practice should be the same for both cases.
>
Yes, not having any other thread to race with is the reason I did not unlock
the iothread. But, I agree that the semantics need to be the same.
I will send an updated patch.
Thanks,
--
Pranith
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2] mttcg: Handle EXCP_ATOMIC exception
2016-11-02 14:25 [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception Pranith Kumar
2016-11-02 16:22 ` Alex Bennée
@ 2016-11-02 16:40 ` Pranith Kumar
2016-11-02 16:49 ` Paolo Bonzini
1 sibling, 1 reply; 6+ messages in thread
From: Pranith Kumar @ 2016-11-02 16:40 UTC (permalink / raw)
To: qemu-devel, alex.bennee; +Cc: pbonzini
The patch enables handling atomic code in the guest. This should be
preferably done in cpu_handle_exception(), but the current assumptions
regarding when we can execute atomic sections cause a deadlock.
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
cpus.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cpus.c b/cpus.c
index 8f98060..299ce7e 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1315,6 +1315,11 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
break;
+ } else if (r == EXCP_ATOMIC) {
+ qemu_mutex_unlock_iothread();
+ cpu_exec_step_atomic(cpu);
+ qemu_mutex_lock_iothread();
+ break;
}
} else if (cpu->stop) {
if (cpu->unplug) {
@@ -1385,6 +1390,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
*/
g_assert(cpu->halted);
break;
+ case EXCP_ATOMIC:
+ qemu_mutex_unlock_iothread();
+ cpu_exec_step_atomic(cpu);
+ qemu_mutex_lock_iothread();
default:
/* Ignore everything else? */
break;
--
2.10.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] mttcg: Handle EXCP_ATOMIC exception
2016-11-02 16:40 ` [Qemu-devel] [PATCH v2] " Pranith Kumar
@ 2016-11-02 16:49 ` Paolo Bonzini
2016-11-02 18:17 ` Alex Bennée
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-11-02 16:49 UTC (permalink / raw)
To: Pranith Kumar, qemu-devel, alex.bennee
On 02/11/2016 17:40, Pranith Kumar wrote:
> The patch enables handling atomic code in the guest. This should be
> preferably done in cpu_handle_exception(), but the current assumptions
> regarding when we can execute atomic sections cause a deadlock.
>
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
> cpus.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/cpus.c b/cpus.c
> index 8f98060..299ce7e 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1315,6 +1315,11 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
> if (r == EXCP_DEBUG) {
> cpu_handle_guest_debug(cpu);
> break;
> + } else if (r == EXCP_ATOMIC) {
> + qemu_mutex_unlock_iothread();
> + cpu_exec_step_atomic(cpu);
> + qemu_mutex_lock_iothread();
> + break;
> }
> } else if (cpu->stop) {
> if (cpu->unplug) {
> @@ -1385,6 +1390,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
> */
> g_assert(cpu->halted);
> break;
> + case EXCP_ATOMIC:
> + qemu_mutex_unlock_iothread();
> + cpu_exec_step_atomic(cpu);
> + qemu_mutex_lock_iothread();
> default:
> /* Ignore everything else? */
> break;
>
Alex, please pick up this patch yourself.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] mttcg: Handle EXCP_ATOMIC exception
2016-11-02 16:49 ` Paolo Bonzini
@ 2016-11-02 18:17 ` Alex Bennée
0 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2016-11-02 18:17 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Pranith Kumar, qemu-devel
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 02/11/2016 17:40, Pranith Kumar wrote:
>> The patch enables handling atomic code in the guest. This should be
>> preferably done in cpu_handle_exception(), but the current assumptions
>> regarding when we can execute atomic sections cause a deadlock.
>>
>> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
>> ---
>> cpus.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/cpus.c b/cpus.c
>> index 8f98060..299ce7e 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -1315,6 +1315,11 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
>> if (r == EXCP_DEBUG) {
>> cpu_handle_guest_debug(cpu);
>> break;
>> + } else if (r == EXCP_ATOMIC) {
>> + qemu_mutex_unlock_iothread();
>> + cpu_exec_step_atomic(cpu);
>> + qemu_mutex_lock_iothread();
>> + break;
>> }
>> } else if (cpu->stop) {
>> if (cpu->unplug) {
>> @@ -1385,6 +1390,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
>> */
>> g_assert(cpu->halted);
>> break;
>> + case EXCP_ATOMIC:
>> + qemu_mutex_unlock_iothread();
>> + cpu_exec_step_atomic(cpu);
>> + qemu_mutex_lock_iothread();
>> default:
>> /* Ignore everything else? */
>> break;
>>
>
> Alex, please pick up this patch yourself.
Yep, I'll apply it to my tree.
>
> Paolo
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-11-02 18:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-02 14:25 [Qemu-devel] [PATCH] mttcg: Handle EXCP_ATOMIC exception Pranith Kumar
2016-11-02 16:22 ` Alex Bennée
2016-11-02 16:30 ` Pranith Kumar
2016-11-02 16:40 ` [Qemu-devel] [PATCH v2] " Pranith Kumar
2016-11-02 16:49 ` Paolo Bonzini
2016-11-02 18:17 ` Alex Bennée
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.