From nobody Wed Nov 5 09:32:31 2025 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 1499587217015126.0128599000542; Sun, 9 Jul 2017 01:00:17 -0700 (PDT) Received: from localhost ([::1]:35283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dU78Z-0003Zv-QX for importer@patchew.org; Sun, 09 Jul 2017 04:00:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dU6zJ-0004R8-6Q for qemu-devel@nongnu.org; Sun, 09 Jul 2017 03:50:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dU6zD-0002zO-WC for qemu-devel@nongnu.org; Sun, 09 Jul 2017 03:50:41 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48037) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dU6zD-0002vJ-O5 for qemu-devel@nongnu.org; Sun, 09 Jul 2017 03:50:35 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4B404208CD; Sun, 9 Jul 2017 03:50:32 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Sun, 09 Jul 2017 03:50:32 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 14154248A1; Sun, 9 Jul 2017 03:50:32 -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=uDH WVS/oxfXkKzY5QBFdeHKwv3yk1QCU7TAslBsJ4MA=; b=F2LqsDxk07t8CHl/Cd0 n2zr0QTBrVpX+N+Nb75Q1R654wJeoSdlnb/9eEmb8sTDYEZOQ8IUy9zZrJiJU0dm yD+AyDPOs0vKPHG5v6dcuaVAoKfQ+7wF7zwnsWe4KIUniwYVkUCaZPd7p0HsvtZ7 4veHhuNA30yhHRz++2yZxjHI= 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=uDHWVS/oxfXkKzY5QBFdeHKwv3yk1QCU7TAslBsJ4 MA=; b=WCXq+jfOfsThCEs5PVOD8Hmzk8+jyciLRopJr4002RCmKw/F1ZsXQLrKz Ilp8BnnL0WD98JHgfuklWTHg39SvOILqS9KMI/sJ1Qpce/M3fsSnuJuGDg+/JAgz NtZdQdcudy1aIMvfL2k1uzPulVaHlM5tidizKQrBgnLB32+W1I9aLu3MGbLlKGbh tADdJzHFASVXgCxwzsyXjKygSHJOiDLOhtPw8AFiUOedOWQg4TPqM8as3Z8vGyEa 7pguybPQIGFfA9ZHlih3kB9DtNSyB/69c4/SoDYHqwswslbsuyjJluheGBpTPi5P uaKi3xet09g5dnGZxLBiPOvq1EwYA== X-ME-Sender: X-Sasl-enc: UOkd9YtvOZ9mZIn7nW/E+ZHP7/4tip83VkDN94hCA78s 1499586632 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Jul 2017 03:49:56 -0400 Message-Id: <1499586614-20507-5-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499586614-20507-1-git-send-email-cota@braap.org> References: <1499586614-20507-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.27 Subject: [Qemu-devel] [PATCH 04/22] tcg: fix corruption of code_time profiling counter upon tb_flush 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" Whenever there is an overflow in code_gen_buffer (e.g. we run out of space in it and have to flush it), the code_time profiling counter ends up with an invalid value (that is, code_time -=3D profile_getclock(), without later on getting +=3D profile_getclock() due to the goto). Fix it by using the ti variable, so that we only update code_time when there is no overflow. Note that in case there is an overflow we fail to account for the elapsed coding time, but this is quite rare so we can probably live with it. "info jit" before/after, roughly at the same time during debian-arm bootup: - before: Statistics: TB flush count 1 TB invalidate count 4665 TLB flush count 998 JIT cycles -615191529184601 (-256329.804 s at 2.4 GHz) translated TBs 302310 (aborted=3D0 0.0%) avg ops/TB 48.4 max=3D438 deleted ops/TB 8.54 avg temps/TB 32.31 max=3D38 avg host code/TB 361.5 avg search data/TB 24.5 cycles/op -42014693.0 cycles/in byte -121444900.2 cycles/out byte -5629031.1 cycles/search byte -83114481.0 gen_interm time -0.0% gen_code time 100.0% optim./code time -0.0% liveness/code time -0.0% cpu_restore count 6236 avg cycles 110.4 - after: Statistics: TB flush count 1 TB invalidate count 4665 TLB flush count 1010 JIT cycles 1996899624 (0.832 s at 2.4 GHz) translated TBs 297961 (aborted=3D0 0.0%) avg ops/TB 48.5 max=3D438 deleted ops/TB 8.56 avg temps/TB 32.31 max=3D38 avg host code/TB 361.8 avg search data/TB 24.5 cycles/op 138.2 cycles/in byte 398.4 cycles/out byte 18.5 cycles/search byte 273.1 gen_interm time 14.0% gen_code time 86.0% optim./code time 19.4% liveness/code time 10.3% cpu_restore count 6372 avg cycles 111.0 Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/tcg/translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a936a5f..72ce445 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1293,7 +1293,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #ifdef CONFIG_PROFILER tcg_ctx.tb_count++; tcg_ctx.interm_time +=3D profile_getclock() - ti; - tcg_ctx.code_time -=3D profile_getclock(); + ti =3D profile_getclock(); #endif =20 /* ??? Overflow could be handled better here. In particular, we @@ -1311,7 +1311,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } =20 #ifdef CONFIG_PROFILER - tcg_ctx.code_time +=3D profile_getclock(); + tcg_ctx.code_time +=3D profile_getclock() - ti; tcg_ctx.code_in_len +=3D tb->size; tcg_ctx.code_out_len +=3D gen_code_size; tcg_ctx.search_out_len +=3D search_size; --=20 2.7.4