qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 03/10] replace spinlock by QemuMutex.


From: Frederic Konrad
Subject: Re: [Qemu-devel] [RFC 03/10] replace spinlock by QemuMutex.
Date: Mon, 02 Feb 2015 09:45:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 29/01/2015 16:25, Peter Maydell wrote:
On 16 January 2015 at 17:19,  <address@hidden> wrote:
From: KONRAD Frederic <address@hidden>

spinlock is only used in two cases:
   * cpu-exec.c: to protect TranslationBlock
   * mem_helper.c: for lock helper in target-i386 (which seems broken).

It's a pthread_mutex_t in user-mode so better using QemuMutex directly in this
case.
It allows as well to reuse tb_lock mutex of TBContext in case of multithread
TCG.

Signed-off-by: KONRAD Frederic <address@hidden>
---
  cpu-exec.c               | 15 +++++++++++----
  include/exec/exec-all.h  |  4 ++--
  linux-user/main.c        |  6 +++---
  target-i386/mem_helper.c | 16 +++++++++++++---
  tcg/i386/tcg-target.c    |  8 ++++++++
  5 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index a4f0eff..1e7513c 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -335,7 +335,9 @@ int cpu_exec(CPUArchState *env)
      SyncClocks sc;

      /* This must be volatile so it is not trashed by longjmp() */
+#if defined(CONFIG_USER_ONLY)
      volatile bool have_tb_lock = false;
+#endif
This work should be removing ifdefs indicating differences between
handling of user-only and softmmu regarding locking and threads,
not adding new ones.

-- PMM
True,
I tried to go step by step to be able to use tb_lock and remove spinlock (which is
qemu_mutex_lock with ifdefs) to avoid a big patch with a lot of changes.

The ifdefs should be removed later in the series (I think).

Fred



reply via email to

[Prev in Thread] Current Thread [Next in Thread]