From nobody Sun Feb 8 17:33:29 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 1539183188660900.5753729341271; Wed, 10 Oct 2018 07:53:08 -0700 (PDT) Received: from localhost ([::1]:57711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFrH-0005R2-Nl for importer@patchew.org; Wed, 10 Oct 2018 10:53:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFnU-0002nu-GB for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAFnP-0004ba-MU for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:41295) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAFnP-0004aP-F0 for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0318C21F86; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 10:49:05 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 93FA4102F0; Wed, 10 Oct 2018 10:49:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=kQovQBwyOE8NRXGBmyghO6a5DpCuC7KJZuJpXboCGBw=; b=wGFp7 1dd1YxNBoBnbGvujoUGiwCn7m4fVPvbvt4ZPXhjNbuHtGLC6pKh4M9M+VmVCiV3o d1p8LnNfqfWhHK7B33+aov39KrzdhaglnC3tys5unYy4jZZHuV3jNQ8s+FaM5gAv 9J3twmtt3kxrVookwnvqyD8Zt8AKYUebQh4B9g= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=kQovQBwyOE8NRXGBmyghO6a5DpCuC 7KJZuJpXboCGBw=; b=xwTKg13WzMfp0NAkk1p+fnJUbVgbWIBlperfCcVuGBGsJ m6JcHtAi+wgonz69pseN+MVjE9Vqj895iXYwSVTRnK/8L65MhI6G58jzAQIxgHLQ eTWUkNnGVOqYUWrXAdPnt4dEmfGEJ6RQmxBZMTbcC/r05Ze0PSelWlL4mybx9oL2 lS38YnfkF5FpGEObBKfpipUmSWWAKyXMav0PTpcftaYkbJRsKnVzzni2D4OVBRzG Cf5FeC+N8wHiieuomAJLTJL4GDIXhWe7pqgkMyMzcRZsCTZ9BHsyRcLQInNEm7um lrmV4A9MelKbl/O8WAS+yUwgXjYHKnKjKDYeUOyRA== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2018 10:48:50 -0400 Message-Id: <20181010144853.13005-2-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010144853.13005-1-cota@braap.org> References: <20181010144853.13005-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [PATCH 1/4] tcg: access cpu->icount_decr.u16.high with atomics 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" Consistently access u16.high with atomics to avoid undefined behaviour in MTTCG. Note that icount_decr.u16.low is only used in icount mode, so regular accesses to it are OK. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/tcg-all.c | 2 +- accel/tcg/translate-all.c | 2 +- qom/cpu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 56dbb56a16..3d25bdcc17 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -51,7 +51,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask) if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); } else { - cpu->icount_decr.u16.high =3D -1; + atomic_set(&cpu->icount_decr.u16.high, -1); if (use_icount && !cpu->can_do_io && (mask & ~old_mask) !=3D 0) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ad5c758246..356dcd0948 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2341,7 +2341,7 @@ void cpu_interrupt(CPUState *cpu, int mask) { g_assert(qemu_mutex_iothread_locked()); cpu->interrupt_request |=3D mask; - cpu->icount_decr.u16.high =3D -1; + atomic_set(&cpu->icount_decr.u16.high, -1); } =20 /* diff --git a/qom/cpu.c b/qom/cpu.c index 92599f3541..20ad54d43f 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -266,7 +266,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->mem_io_pc =3D 0; cpu->mem_io_vaddr =3D 0; cpu->icount_extra =3D 0; - cpu->icount_decr.u32 =3D 0; + atomic_set(&cpu->icount_decr.u32, 0); cpu->can_do_io =3D 1; cpu->exception_index =3D -1; cpu->crash_occurred =3D false; --=20 2.17.1 From nobody Sun Feb 8 17:33:29 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539183098700627.9809700324249; Wed, 10 Oct 2018 07:51:38 -0700 (PDT) Received: from localhost ([::1]:57701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFpf-00044p-Gq for importer@patchew.org; Wed, 10 Oct 2018 10:51:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFnU-0002nw-MF for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAFnP-0004bQ-Lv for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:53327) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAFnP-0004aR-Fp for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4FA3721D19; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 10:49:05 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BD9ED102F2; Wed, 10 Oct 2018 10:49:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=m4aJvnAPBbEyHlFUNekIB6aLbm94eCE+qBmYPRVUKdA=; b=CYJGh 8T81kWGy7u5moC8/NdtRYQFAmYhf5Yfk9PdZQlLL0yhjRzHeKoKor1BY0JuejhK4 vbk/lYqBFWAUbupsx21k+q/7cuVxNRXggaZhsD2vm3V6D7w8cKeOmE4WZldpqMiO xW8Tgko/ruw4KtRLgyiVDXqDCPA0B3m6wNJROU= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=m4aJvnAPBbEyHlFUNekIB6aLbm94e CE+qBmYPRVUKdA=; b=PEQm7aPEQHt2x5fIyUhCB6c1EoMOhi9ZAXoIIyNoFZOXD yfGjAjFsBPqata68nsa2OUmzYDxSiYNg7tyACFN1VlLuLjxVCurxslPLSIY/3qnS QILcbX+glT/PxlEGOoR1pKc4dzFFscEAb48W4EcjFJ8lQsh2pUtQJr2ck7PQ7myy QwbYRFV/8MVmlRvLdwMzEZEPYAl0/tkxd9fWbO/3/MmOqRLWsjEFMfZQDEkYeOVX HNdVZMN2+wCZs+8bbyDBHmWF6XmVOurHZfYYNvTBAOR+mnd+tbleg/CFHOq6+1L5 mtUEl5hIEML/THZZpykh0DvlRKy0tKJVxOxKTYxXQ== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2018 10:48:51 -0400 Message-Id: <20181010144853.13005-3-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010144853.13005-1-cota@braap.org> References: <20181010144853.13005-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [PATCH 2/4] tcg: fix use of uninitialized variable under CONFIG_PROFILER 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" We forgot to initialize n in commit 15fa08f845 ("tcg: Dynamically allocate TCGOps", 2017-12-29). Signed-off-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index f27b22bd3c..8f26916b99 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3430,7 +3430,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) =20 #ifdef CONFIG_PROFILER { - int n; + int n =3D 0; =20 QTAILQ_FOREACH(op, &s->ops, link) { n++; --=20 2.17.1 From nobody Sun Feb 8 17:33:29 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 15391833127021013.7023973422813; Wed, 10 Oct 2018 07:55:12 -0700 (PDT) Received: from localhost ([::1]:57720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFtH-0007Cr-H3 for importer@patchew.org; Wed, 10 Oct 2018 10:55:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFnU-0002nx-Mj for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAFnP-0004bf-MV for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48271) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAFnP-0004aZ-F1 for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5B2C822123; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 10:49:05 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id F1DC5102EC; Wed, 10 Oct 2018 10:49:04 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=RnnyextfCFUjAOna+t7W8gWY39U5DeplciMPVmW8uE0=; b=bQBVe i694fQxDiaixsyQu76vSNIi8vWgjcUEuSWz5O/uOGZXVNLtaV6hfyOuMz35uOAEp roHRkZ6sNoLDgsR3hP9GLZmNYqdDzOgvQyVi7uvmrjAZj0iorSuwfcBN15Zzs6XT DCZv7SCGpg8ohlLw/cpsiSesAuG6swDqsXBqLw= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=RnnyextfCFUjAOna+t7W8gWY39U5D eplciMPVmW8uE0=; b=JEk/25yky5dJT7OH4bhymj46EIdgvB6xGctlb/mP5RNhc EXJNX/DKlpZlNC4ClRFohIhc9oZk7H9SE7csfTZ8wghuYunv4sCN/My8prKGfPC5 Gw73TF203tywiRWPQZvB8SiaOMGiZ8L1A6sJPsGdMZPhmj89KgbSXf/m4mAFyyKo 7nF8FBw6b7zaYTdnc0bBmETU+/3G5Tp44qYsCcQO0yfcAea2jTmCu5b4gUOb9Xtr 5DYsZD0XznaCVepTvuY0/rHjTYG15UelTW9dUbVJC6oUo2WYqxbwfhxQM+GczgeL NBiBZalnH8+W7CcA8BCfENSh4Kn2ol831Rv8Aiplw== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2018 10:48:52 -0400 Message-Id: <20181010144853.13005-4-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010144853.13005-1-cota@braap.org> References: <20181010144853.13005-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [PATCH 3/4] tcg: plug holes in struct TCGProfile 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" This plugs two 4-byte holes in 64-bit. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index f9f12378e9..d80ef2a883 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -633,8 +633,8 @@ typedef struct TCGProfile { int64_t tb_count; int64_t op_count; /* total insn count */ int op_count_max; /* max insn per TB */ - int64_t temp_count; int temp_count_max; + int64_t temp_count; int64_t del_op_count; int64_t code_in_len; int64_t code_out_len; --=20 2.17.1 From nobody Sun Feb 8 17:33:29 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 1539183100203231.6804913427262; Wed, 10 Oct 2018 07:51:40 -0700 (PDT) Received: from localhost ([::1]:57703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFpl-00047E-7t for importer@patchew.org; Wed, 10 Oct 2018 10:51:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAFnU-0002nv-MH for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAFnP-0004bc-Mk for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:57409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAFnP-0004ah-F1 for qemu-devel@nongnu.org; Wed, 10 Oct 2018 10:49:07 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8AEDF21F03; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 10:49:05 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 30B31102A0; Wed, 10 Oct 2018 10:49:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=+wZF9DPuJOSNNhPKQUg8G+MTdjeU3DkiGqMf92cqlDg=; b=UWF8c fUiUIKOxFrd/88On2nt9zaFYWlIs/d8SWl1KCL0nwgqx1xQctZ15r0slyEZ1e0j+ weLsvvO76RrU4cHupYs8bhtHSKMNZhDP65tttKQkwNuaast7WM0Rke7iLiyscZPY G+8whta5sToIaZgIrNIeuHAvdviCgJsZNgnXwg= 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-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=+wZF9DPuJOSNNhPKQUg8G+MTdjeU3 DkiGqMf92cqlDg=; b=CwmSy46qzukBzvPl53zdAmoWU1gjSfmAQC1y/PQKT8Kyw i+UzZR+vRW8CSAEE3IyenDHZDt9aAsWz2C1fDzQfFuZxh5KutNwiqrS2/r72uoi0 tQWX/FACwnAg/e5hOoSh8MiIMZvRjublJNNM0i6xS2r/plOrKaEstPXZO3tfwqje LAHoCf9EJpY7Mlu3/ki5KJJL07igTmbOtzUJ4fs1C3ifpD1hIKFaV4ma0O34SCaU 631SC3CoyhIrKe2Qq5YFF7+ixN66fKfca0z+Q+iM+2JmFUG2NZoyUnaR1ixJrFIl JQhd4MYafbP70SNGZhC0+Z8mGbqEx5mlWhvRJtGtA== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2018 10:48:53 -0400 Message-Id: <20181010144853.13005-5-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010144853.13005-1-cota@braap.org> References: <20181010144853.13005-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [PATCH 4/4] tcg: distribute tcg_time into TCG contexts 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" When we implemented per-vCPU TCG contexts, we forgot to also distribute the tcg_time counter, which has remained as a global accessed without any serialization, leading to potentially missed counts. Fix it by distributing the field over the TCG contexts, embedding it into TCGProfile with a field called "cpu_exec_time", which is more descriptive than "tcg_time". Add a function to query this value directly, and for completeness, fill in the field in tcg_profile_snapshot, even though its callers do not use it. Signed-off-by: Emilio G. Cota --- include/qemu/timer.h | 1 - tcg/tcg.h | 2 ++ cpus.c | 3 ++- monitor.c | 13 ++++++++++--- tcg/tcg.c | 23 +++++++++++++++++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index a005ed2692..dfecd03e28 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -1046,7 +1046,6 @@ static inline int64_t profile_getclock(void) return get_clock(); } =20 -extern int64_t tcg_time; extern int64_t dev_time; #endif =20 diff --git a/tcg/tcg.h b/tcg/tcg.h index d80ef2a883..c59f254e27 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -629,6 +629,7 @@ typedef struct TCGOp { QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); =20 typedef struct TCGProfile { + int64_t cpu_exec_time; int64_t tb_count1; int64_t tb_count; int64_t op_count; /* total insn count */ @@ -1002,6 +1003,7 @@ int tcg_check_temp_count(void); #define tcg_check_temp_count() 0 #endif =20 +int64_t tcg_cpu_exec_time(void); void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf); void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf); =20 diff --git a/cpus.c b/cpus.c index 361678e459..cce64874e6 100644 --- a/cpus.c +++ b/cpus.c @@ -1425,7 +1425,8 @@ static int tcg_cpu_exec(CPUState *cpu) ret =3D cpu_exec(cpu); cpu_exec_end(cpu); #ifdef CONFIG_PROFILER - tcg_time +=3D profile_getclock() - ti; + atomic_set(&tcg_ctx->prof.cpu_exec_time, + tcg_ctx->prof.cpu_exec_time + profile_getclock() - ti); #endif return ret; } diff --git a/monitor.c b/monitor.c index b9258a7438..823b5a1099 100644 --- a/monitor.c +++ b/monitor.c @@ -83,6 +83,7 @@ #include "sysemu/cpus.h" #include "sysemu/iothread.h" #include "qemu/cutils.h" +#include "tcg/tcg.h" =20 #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" @@ -1966,16 +1967,22 @@ static void hmp_info_numa(Monitor *mon, const QDict= *qdict) =20 #ifdef CONFIG_PROFILER =20 -int64_t tcg_time; int64_t dev_time; =20 static void hmp_info_profile(Monitor *mon, const QDict *qdict) { + static int64_t last_cpu_exec_time; + int64_t cpu_exec_time; + int64_t delta; + + cpu_exec_time =3D tcg_cpu_exec_time(); + delta =3D cpu_exec_time - last_cpu_exec_time; + monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n", - tcg_time, tcg_time / (double)NANOSECONDS_PER_SECOND); - tcg_time =3D 0; + delta, delta / (double)NANOSECONDS_PER_SECOND); + last_cpu_exec_time =3D cpu_exec_time; dev_time =3D 0; } #else diff --git a/tcg/tcg.c b/tcg/tcg.c index 8f26916b99..e85133ef05 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -30,6 +30,7 @@ /* Define to jump the ELF file used to communicate with GDB. */ #undef DEBUG_JIT =20 +#include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/host-utils.h" #include "qemu/timer.h" @@ -3361,6 +3362,7 @@ void tcg_profile_snapshot(TCGProfile *prof, bool coun= ters, bool table) const TCGProfile *orig =3D &s->prof; =20 if (counters) { + PROF_ADD(prof, orig, cpu_exec_time); PROF_ADD(prof, orig, tb_count1); PROF_ADD(prof, orig, tb_count); PROF_ADD(prof, orig, op_count); @@ -3412,11 +3414,32 @@ void tcg_dump_op_count(FILE *f, fprintf_function cp= u_fprintf) prof.table_op_count[i]); } } + +int64_t tcg_cpu_exec_time(void) +{ + unsigned int n_ctxs =3D atomic_read(&n_tcg_ctxs); + unsigned int i; + int64_t ret =3D 0; + + for (i =3D 0; i < n_ctxs; i++) { + const TCGContext *s =3D atomic_read(&tcg_ctxs[i]); + const TCGProfile *prof =3D &s->prof; + + ret +=3D atomic_read(&prof->cpu_exec_time); + } + return ret; +} #else void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) { cpu_fprintf(f, "[TCG profiler not compiled]\n"); } + +int64_t tcg_cpu_exec_time(void) +{ + error_report("%s: TCG profiler not compiled", __func__); + exit(EXIT_FAILURE); +} #endif =20 =20 --=20 2.17.1