From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj3UC-0001Cv-6W for qemu-devel@nongnu.org; Thu, 24 Mar 2016 07:31:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj3U6-0002pY-Kt for qemu-devel@nongnu.org; Thu, 24 Mar 2016 07:31:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj3U6-0002pT-FJ for qemu-devel@nongnu.org; Thu, 24 Mar 2016 07:31:26 -0400 References: <1458815961-31979-1-git-send-email-sergey.fedorov@linaro.org> <1458815961-31979-6-git-send-email-sergey.fedorov@linaro.org> From: Paolo Bonzini Message-ID: <56F3D009.1030603@redhat.com> Date: Thu, 24 Mar 2016 12:31:21 +0100 MIME-Version: 1.0 In-Reply-To: <1458815961-31979-6-git-send-email-sergey.fedorov@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/8] tcg: Clarify "thread safaty" check in tb_add_jump() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sergey.fedorov@linaro.org, qemu-devel@nongnu.org Cc: Sergey Fedorov , Richard Henderson , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Peter Crosthwaite On 24/03/2016 11:39, sergey.fedorov@linaro.org 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. Paolo