[Top][All Lists]

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

Re: [Qemu-devel] [PATCH 5/8] tcg: Clarify "thread safaty" check in tb_ad

From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 5/8] tcg: Clarify "thread safaty" check in tb_add_jump()
Date: Thu, 24 Mar 2016 12:31:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 24/03/2016 11:39, address@hidden wrote:
> +    /* FIXME: This test provides only some probablistic "thread safety" for
> +     * user-mode emulation; appropriate synchronization/locking scheme should
> +     * be implemented.
> +     */

There is appropriate locking.  This code:

       if (next_tb != 0 && tb->page_addr[1] == -1
           && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
           tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),
                       next_tb & TB_EXIT_MASK, tb);

in cpu-exec.c runs under tb_lock.  However, two threads can decide to
call tb_add_jump at the same time outside the lock, so we have to check
inside the lock whether someone has already done the work.

What the comment means is that, in single-threaded scenarios (current
TCG and single-threaded user emulation), tb->jmp_list_next[n] is only
set once.


reply via email to

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