All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
@ 2015-09-03 19:24 Aníbal Limón
  0 siblings, 0 replies; 3+ messages in thread
From: Aníbal Limón @ 2015-09-03 19:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.purdie, Aníbal Limón

When QEMU starts the RCU thread executes qemu_mutex_lock_thread
causing error "qemu:qemu_cpu_kick_thread: No such process" and exits.

This isn't occur frequently but in glibc the thread id can exist and
this not guarantee that the thread is on active/running state. If is
inserted a sleep(1) after newthread assignment [1] the issue appears.

So not make assumption that thread exist if first_cpu->thread is set
then change the validation of cpu to created that is set into cpu
threads (kvm, tcg, dummy).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_create.c;h=d10f4ea8004e1d8f3a268b95cc0f8d93b8d89867;hb=HEAD#l621

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 7e4786e..05e5400 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1171,7 +1171,7 @@ void qemu_mutex_lock_iothread(void)
      * TCG code execution.
      */
     if (!tcg_enabled() || qemu_in_vcpu_thread() ||
-        !first_cpu || !first_cpu->thread) {
+        !first_cpu || !first_cpu->created) {
         qemu_mutex_lock(&qemu_global_mutex);
         atomic_dec(&iothread_requesting_mutex);
     } else {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
  2015-09-03 20:48 Aníbal Limón
@ 2015-09-04  8:15 ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-09-04  8:15 UTC (permalink / raw)
  To: Aníbal Limón, qemu-devel, qemu-stable



On 03/09/2015 22:48, Aníbal Limón wrote:
> When QEMU starts the RCU thread executes qemu_mutex_lock_thread
> causing error "qemu:qemu_cpu_kick_thread: No such process" and exits.
> 
> This isn't occur frequently but in glibc the thread id can exist and
> this not guarantee that the thread is on active/running state. If is
> inserted a sleep(1) after newthread assignment [1] the issue appears.
> 
> So not make assumption that thread exist if first_cpu->thread is set
> then change the validation of cpu to created that is set into cpu
> threads (kvm, tcg, dummy).
> 
> [1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_create.c;h=d10f4ea8004e1d8f3a268b95cc0f8d93b8d89867;hb=HEAD#l621
> 
> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>

Cc: qemu-stable@nongnu.org

Paolo

> ---
>  cpus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 7e4786e..05e5400 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1171,7 +1171,7 @@ void qemu_mutex_lock_iothread(void)
>       * TCG code execution.
>       */
>      if (!tcg_enabled() || qemu_in_vcpu_thread() ||
> -        !first_cpu || !first_cpu->thread) {
> +        !first_cpu || !first_cpu->created) {
>          qemu_mutex_lock(&qemu_global_mutex);
>          atomic_dec(&iothread_requesting_mutex);
>      } else {
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
@ 2015-09-03 20:48 Aníbal Limón
  2015-09-04  8:15 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Aníbal Limón @ 2015-09-03 20:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aníbal Limón

When QEMU starts the RCU thread executes qemu_mutex_lock_thread
causing error "qemu:qemu_cpu_kick_thread: No such process" and exits.

This isn't occur frequently but in glibc the thread id can exist and
this not guarantee that the thread is on active/running state. If is
inserted a sleep(1) after newthread assignment [1] the issue appears.

So not make assumption that thread exist if first_cpu->thread is set
then change the validation of cpu to created that is set into cpu
threads (kvm, tcg, dummy).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_create.c;h=d10f4ea8004e1d8f3a268b95cc0f8d93b8d89867;hb=HEAD#l621

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 7e4786e..05e5400 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1171,7 +1171,7 @@ void qemu_mutex_lock_iothread(void)
      * TCG code execution.
      */
     if (!tcg_enabled() || qemu_in_vcpu_thread() ||
-        !first_cpu || !first_cpu->thread) {
+        !first_cpu || !first_cpu->created) {
         qemu_mutex_lock(&qemu_global_mutex);
         atomic_dec(&iothread_requesting_mutex);
     } else {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-04  8:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 19:24 [Qemu-devel] [PATCH] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init Aníbal Limón
2015-09-03 20:48 Aníbal Limón
2015-09-04  8:15 ` Paolo Bonzini

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.