[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qemu_mutex_iothread_locked not correctly synchr
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] qemu_mutex_iothread_locked not correctly synchronized |
Date: |
Tue, 24 Nov 2015 16:54:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 24/11/2015 16:43, David Engraf wrote:
> Commit afbe70535ff1a8a7a32910cc15ebecc0ba92e7da introduced the function
> qemu_mutex_iothread_locked to avoid recursive locking of the iothread
> lock. The iothread_locked variable uses the __thread attribute which
> results in a per thread storage location whereas the qemu_global_mutex
> is not thread specific. This leads to race conditions because the
> variable is not in sync between threads.
Frankly, this makes no sense. You're modifying the
qemu_mutex_iothread_locked function to return whether _some_ thread has
taken the mutex, but the function tells you whether _the calling_ thread
has taken the mutex (that's the point about recursive locking). This
breaks the callers of qemu_mutex_iothread_locked completely.
The variable need not be in sync between the different threads; each
thread only needs to know about itself. The current code works because:
1) the iothread mutex is not locked before qemu_mutex_lock_iothread
2) the iothread mutex is not locked after qemu_mutex_lock_iothread
3) qemu_cond_wait doesn't matter because the thread does not run during
a qemu_cond_wait.
> I triggered this problem reproducible on a Windows machine whereas Linux
> works fine.
What are the symptoms, and what is your Windows compiler?
Paolo
- [Qemu-devel] [PATCH] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/24
- Re: [Qemu-devel] [PATCH] qemu_mutex_iothread_locked not correctly synchronized,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, Paolo Bonzini, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, Paolo Bonzini, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, Paolo Bonzini, 2015/11/25
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/26
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, Stefan Weil, 2015/11/26
- Re: [Qemu-devel] [PATCH v2] qemu_mutex_iothread_locked not correctly synchronized, David Engraf, 2015/11/26