From patchwork Mon Aug 7 23:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 798969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=braap.org header.i=@braap.org header.b="2mFi9iPW"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="qej2ohpi"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xRDvf5m91z9sPr for ; Tue, 8 Aug 2017 09:56:30 +1000 (AEST) Received: from localhost ([::1]:40053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dersq-0000KF-Eu for incoming@patchwork.ozlabs.org; Mon, 07 Aug 2017 19:56:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1derpM-0005yT-N7 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 19:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1derpH-0005jL-Nk for qemu-devel@nongnu.org; Mon, 07 Aug 2017 19:52:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43949) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1derpH-0005ir-IR for qemu-devel@nongnu.org; Mon, 07 Aug 2017 19:52:47 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E4C272196C; Mon, 7 Aug 2017 19:52:46 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Mon, 07 Aug 2017 19:52:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=SC2 sQpJ+JQ3295sZtjk7QklUHX2J7iGnTUHLbsmS7XU=; b=2mFi9iPWBv7wZ+2II8B dPXjpcdk82cdKEy742+ixUlsZf4M/32EzV441oRyEzhqIrsxtNHBBQ/GeD/86jvG LV+hY7R/yKUebH1koh/HgbSiL2lJo9oSVFHTtymm2U9au0upPUHHbZG3JBfO5ZP5 2b1BYvfVFGs+JbndjZdXZJ3s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=SC2sQpJ+JQ3295sZtjk7QklUHX2J7iGnTUHLbsmS7 XU=; b=qej2ohpiS67dwVPyEovqdtIPgNHpuM7lHmrIzCcBWv/4Tp+0q3XW3HC8J TFPNophe305LUhQpuhcb6FLyPx1sD5Cj6FYVBlBqdzsvIk7UoBjmhiU3s2WI+1GQ VDNb40jBAEsFUGMod9R1k11QetRuB3xfl/Y+2VWZX3yBM7TrZQylhKLIYnIO+3t/ T7eNXcrzhRqA84MbzJgl4/pWzDTIxCRcltn5XJoM+3pTdsIHG0xEVq9GGMfiqaGr gKqo96zzqREsm/dhyqWd/6iwNyOA2P006u5pA+uUn4stB68YvyJgGkddz+eY/KRj x6RAYbHxlgDwsf8ymxmzmXSe9O38g== X-ME-Sender: X-Sasl-enc: ElolCUNgcXM4uh9hS2nkxpEIXaqUo+A0xN0edYKZ+KJa 1502149966 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id AA190240B1; Mon, 7 Aug 2017 19:52:46 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 7 Aug 2017 19:52:27 -0400 Message-Id: <1502149958-23381-12-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502149958-23381-1-git-send-email-cota@braap.org> References: <1502149958-23381-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH 11/22] translate-all: exit from tb_phys_invalidate if qht_remove fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Groundwork for supporting parallel TCG generation. Once tb_lock goes away, it is conceivable that two (or more) threads might race while invalidating the same TB. We currently do not check for this, which means we would wrongly invalidate the same TB more than once. Fix this by using qht_remove as the synchronization point; if it fails, that means the TB has already been invalidated, and therefore there is nothing left to do in tb_phys_invalidate. Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8e5e5b2..0e3d223 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1061,7 +1061,9 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, tb->trace_vcpu_dstate); - qht_remove(&tb_ctx.htable, tb, h); + if (!qht_remove(&tb_ctx.htable, tb, h)) { + return; + } /* remove the TB from the page list */ if (tb->page_addr[0] != page_addr) {