qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Konrad <fred.konrad@greensocs.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: mttcg@greensocs.com
Subject: Re: [Qemu-devel] [PATCH 03/10] replace spinlock by QemuMutex.
Date: Thu, 13 Aug 2015 15:21:09 +0200	[thread overview]
Message-ID: <55CC99C5.9070904@greensocs.com> (raw)
In-Reply-To: <55CC97BF.9030408@redhat.com>

On 13/08/2015 15:12, Paolo Bonzini wrote:
>
> On 13/08/2015 14:17, Frederic Konrad wrote:
>>> diff --git a/linux-user/main.c b/linux-user/main.c
>>> index fdee981..fd06ce9 100644
>>> --- a/linux-user/main.c
>>> +++ b/linux-user/main.c
>>> @@ -107,7 +107,7 @@ static int pending_cpus;
>>>    /* Make sure everything is in a consistent state for calling
>>> fork().  */
>>>    void fork_start(void)
>>>    {
>>> -    pthread_mutex_lock(&tcg_ctx.tb_ctx.tb_lock);
>>> +    qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock);
>>>        pthread_mutex_lock(&exclusive_lock);
>>>        mmap_fork_start();
>>>    }
>>> @@ -129,11 +129,11 @@ void fork_end(int child)
>>>            pthread_mutex_init(&cpu_list_mutex, NULL);
>>>            pthread_cond_init(&exclusive_cond, NULL);
>>>            pthread_cond_init(&exclusive_resume, NULL);
>>> -        pthread_mutex_init(&tcg_ctx.tb_ctx.tb_lock, NULL);
>>> +        qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock);
>>>            gdbserver_fork(thread_cpu);
>>>        } else {
>>>            pthread_mutex_unlock(&exclusive_lock);
>>> -        pthread_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
>>> +        qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
>> We might want to use tb_lock/unlock in user code as well instead of
>> calling directly qemu_mutex_* ?
> You cannot do that because of the recursive locking assertions; the
> child is not using qemu_mutex_unlock, it's using qemu_mutex_init.  So I
> would have to add some kind of tb_lock_reset_after_fork() function which
> is a bit ugly.

True.

Fred
>>> @@ -676,6 +709,7 @@ static inline void code_gen_alloc(size_t tb_size)
>>>                CODE_GEN_AVG_BLOCK_SIZE;
>>>        tcg_ctx.tb_ctx.tbs =
>>>                g_malloc(tcg_ctx.code_gen_max_blocks *
>>> sizeof(TranslationBlock));
>>> +    qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock);
>> Maybe we can initialize the mutex only for CONFIG_USER_ONLY?
> It's okay, it doesn't consume system resources.
>
> Paolo

  reply	other threads:[~2015-08-13 13:21 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 16:40 [Qemu-devel] [PATCH 00/10] translate-all.c thread-safety Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 01/10] cpus: protect work list with work_mutex Paolo Bonzini
2015-08-28 14:33   ` Peter Maydell
2015-08-12 16:40 ` [Qemu-devel] [PATCH 02/10] cpus: remove tcg_halt_cond global variable Paolo Bonzini
2015-08-13 13:05   ` Frederic Konrad
2015-08-13 13:08     ` Paolo Bonzini
2015-08-13 13:19       ` Frederic Konrad
2015-08-28 14:36   ` Peter Maydell
2015-08-29  6:52     ` Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 03/10] replace spinlock by QemuMutex Paolo Bonzini
2015-08-13 12:17   ` Frederic Konrad
2015-08-13 13:12     ` Paolo Bonzini
2015-08-13 13:21       ` Frederic Konrad [this message]
2015-08-28 14:49   ` Peter Maydell
2015-08-28 14:53     ` Frederic Konrad
2015-08-29  6:51       ` Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 04/10] exec-all: remove non-TCG stuff from exec-all.h header Paolo Bonzini
2015-08-28 14:53   ` Peter Maydell
2015-08-29  6:55     ` Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 05/10] cpu-exec: elide more icount code if CONFIG_USER_ONLY Paolo Bonzini
2015-08-13 13:14   ` Frederic Konrad
2015-08-13 14:06     ` Paolo Bonzini
2015-08-28 14:56   ` Peter Maydell
2015-08-29  7:07     ` Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 06/10] tcg: code_bitmap is not used by user-mode emulation Paolo Bonzini
2015-08-28 14:57   ` Peter Maydell
2015-08-29  7:13     ` Paolo Bonzini
2015-08-12 16:40 ` [Qemu-devel] [PATCH 07/10] tcg: comment on which functions have to be called with mmap_lock held Paolo Bonzini
2015-08-28 15:33   ` Peter Maydell
2015-08-29  6:57     ` Paolo Bonzini
2015-08-12 16:41 ` [Qemu-devel] [PATCH 08/10] tcg: add memory barriers in page_find_alloc accesses Paolo Bonzini
2015-08-12 20:37   ` Emilio G. Cota
2015-08-13  8:13     ` Paolo Bonzini
2015-08-13 19:50       ` Emilio G. Cota
2015-08-28 15:40   ` Peter Maydell
2015-08-29  6:58     ` Paolo Bonzini
2015-08-12 16:41 ` [Qemu-devel] [PATCH 09/10] exec: make mmap_lock/mmap_unlock globally available Paolo Bonzini
2015-08-28 15:42   ` Peter Maydell
2015-08-12 16:41 ` [Qemu-devel] [PATCH 10/10] cpu-exec: fix lock hierarchy for user-mode emulation Paolo Bonzini
2015-08-28 15:59   ` Peter Maydell
2015-08-12 16:41 ` [Qemu-devel] [PATCH 11/10] tcg: comment on which functions have to be called with tb_lock held Paolo Bonzini
2015-08-13 12:51   ` Frederic Konrad
2015-08-13 12:59     ` Paolo Bonzini
2015-08-13 13:32       ` Frederic Konrad
2015-08-13 14:39         ` Paolo Bonzini
2015-08-13 15:32           ` Peter Maydell
2015-08-13 16:20             ` Paolo Bonzini
2015-08-12 16:41 ` [Qemu-devel] [PATCH 12/10] tcg: protect TBContext with tb_lock Paolo Bonzini
2015-08-13 12:57   ` Frederic Konrad
2015-08-13 13:01     ` Paolo Bonzini
2015-08-13 13:04       ` Frederic Konrad
2015-08-14  9:26 ` [Qemu-devel] [PATCH 00/10] translate-all.c thread-safety Frederic Konrad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55CC99C5.9070904@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=mttcg@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).