From nobody Mon Feb 9 13:22:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502150258694413.1476757703499; Mon, 7 Aug 2017 16:57:38 -0700 (PDT) Received: from localhost ([::1]:40059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dertv-0001Ty-TS for importer@patchew.org; Mon, 07 Aug 2017 19:57:35 -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 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) 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 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h =3D tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MA= SK, tb->trace_vcpu_dstate); - qht_remove(&tb_ctx.htable, tb, h); + if (!qht_remove(&tb_ctx.htable, tb, h)) { + return; + } =20 /* remove the TB from the page list */ if (tb->page_addr[0] !=3D page_addr) { --=20 2.7.4