From patchwork Thu Mar 24 10:39:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sergey.fedorov@linaro.org X-Patchwork-Id: 8659531 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F007AC0553 for ; Thu, 24 Mar 2016 10:41:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EBBC2038A for ; Thu, 24 Mar 2016 10:41:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ABF7C2037F for ; Thu, 24 Mar 2016 10:41:52 +0000 (UTC) Received: from localhost ([::1]:49154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj2i8-00048P-4e for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Mar 2016 06:41:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj2gD-0001AS-HB for qemu-devel@nongnu.org; Thu, 24 Mar 2016 06:39:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj2gC-0007tP-FW for qemu-devel@nongnu.org; Thu, 24 Mar 2016 06:39:53 -0400 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:33358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj2gC-0007t5-8O for qemu-devel@nongnu.org; Thu, 24 Mar 2016 06:39:52 -0400 Received: by mail-lb0-x22b.google.com with SMTP id oe12so27546277lbc.0 for ; Thu, 24 Mar 2016 03:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i4NEQCYuUCWHo3R1lFGqhOxgS+QAfI9NJoEFD1ztIQk=; b=D/VDgSVxlTN4jLCmPkNGda4sgQNrrH/n2xIOP/1y3KprKU+b18hT7T4D44KLU8w66A gSUE198tfx1Apmu3YwYpIBCpz9QY7urz016Lk/lE8B/QIUqizXC/txr9id+/L5EdieUL qR9eiDhTZqZTdqAFgMw25OV/Y87G8JVvGWj78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i4NEQCYuUCWHo3R1lFGqhOxgS+QAfI9NJoEFD1ztIQk=; b=BqcxjQ5q52jfy3VaswI80+k9KILp9KAjrZIyo7q02YW77oG7CjLJS+oyL0cGOPo2hP AQpSIxdTaDdauh108TXwUGNF50dpX//BOVMZk9FU1H/cKhERepNhjetHS+yv+a5RJpkX C783vZapdkRXr2VJxpuFonxRSRya2bU6aUtIUVa0o8mQWPGpMPl/h0y25B49xQ7M3Ime L6OLbXLAnCiq6PPP9Ehb0SDIKJBYpSekB3i3SkqmQOTaiJRUzAHp4X6xiuzV7JoAZ8pP qtSmL2z2Er1pLdNSekgDu+Tx9eAX1p42FcTOJiwc/CPXDN2gCMLykIz+qIz97YDg65dd FrCw== X-Gm-Message-State: AD7BkJJThFQnGuxbxALSzXlMbn9Yw76SkkEHmch+pJNPM1esuiHInjAxNBYy34eGPzCQUnwV X-Received: by 10.112.137.228 with SMTP id ql4mr3163167lbb.49.1458815991536; Thu, 24 Mar 2016 03:39:51 -0700 (PDT) Received: from localhost.localdomain ([195.91.132.170]) by smtp.gmail.com with ESMTPSA id jm10sm1069454lbc.34.2016.03.24.03.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Mar 2016 03:39:50 -0700 (PDT) From: sergey.fedorov@linaro.org To: qemu-devel@nongnu.org Date: Thu, 24 Mar 2016 13:39:18 +0300 Message-Id: <1458815961-31979-6-git-send-email-sergey.fedorov@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458815961-31979-1-git-send-email-sergey.fedorov@linaro.org> References: <1458815961-31979-1-git-send-email-sergey.fedorov@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::22b Cc: Sergey Fedorov , Peter Crosthwaite , Paolo Bonzini , Sergey Fedorov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [Qemu-devel] [PATCH 5/8] tcg: Clarify "thread safaty" check in tb_add_jump() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sergey Fedorov The check does not give an absolute guarantee of thread safety because there still may be a race condition between two threads which both have just read zero from jmp_list_next[n] and proceed with list modification. Clarify this in the comment to attract here some attention. Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov --- include/exec/exec-all.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index cd96219a89e7..4f36d109ac7f 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -390,7 +390,10 @@ static inline void tb_set_jmp_target(TranslationBlock *tb, static inline void tb_add_jump(TranslationBlock *tb, int n, TranslationBlock *tb_next) { - /* NOTE: this test is only needed for thread safety */ + /* FIXME: This test provides only some probablistic "thread safety" for + * user-mode emulation; appropriate synchronization/locking scheme should + * be implemented. + */ if (!tb->jmp_list_next[n]) { /* patch the native jump address */ tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr);