From patchwork Tue Oct 10 19:29:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9997113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AECF0601AE for ; Tue, 10 Oct 2017 19:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E07328747 for ; Tue, 10 Oct 2017 19:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9303528748; Tue, 10 Oct 2017 19:31:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id BC8D22874A for ; Tue, 10 Oct 2017 19:31:33 +0000 (UTC) Received: from localhost ([::1]:36798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20FY-0000X7-QW for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Oct 2017 15:31:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20EG-0000V3-Ji for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e20EE-0004v2-Az for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:12 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:48756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e20EE-0004ui-2U for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:10 -0400 Received: by mail-pf0-x233.google.com with SMTP id b79so5987003pfk.5 for ; Tue, 10 Oct 2017 12:30:09 -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 :mime-version:content-transfer-encoding; bh=uWX8ltUJ41jzpP0mhxc6dOVFBO5YtrjkEa7vnTfdaYc=; b=hNLSzppTauUp5GpmeIAY9Zpm1R1FY3n381q7DMTOKjmyiwcidcg7JSBRFIhmx3MTpy QlcUBBbrSFlJTdrJZy19Kub4TihZQQD6KGkxgTw8F8zr9QdaFIh9Q0kSsxpahQiQL1Fm M1NOhQsWMr3k4prTfDip3qNzCALJR82dwL2wE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uWX8ltUJ41jzpP0mhxc6dOVFBO5YtrjkEa7vnTfdaYc=; b=iL6dm3aIBDIEv/A89rT3IdnuaLUNmShBkmbJjQYHMkFj+eWjYUpXSO9CGd7zXu1xKL B93gcaFqevsm+jQzia/NDrq5gs5Z0IZRvVhYTJD12byGJUCcl+va/pTsOBpWCQlgR9ZK JcnnqJRRZBwTqeNLDYYSXy26+xjLhc5P59gSAsvuHYtZFQWho8t0DU0YE2Y0OSGw244S PDetkodSH4DsjeGmNAJhXC30A13sb27A06riFeMkMJYWmzpqqlfqhBKKpZysGC5dfIKj CMQjL9BM1tX70zQl7Dvh9GQq5oEOYAD9vD9hQRb6AOqSXFnGTYgqzpRdigsp8wvfQJxm wJ2A== X-Gm-Message-State: AMCzsaWaAgn0eTjOXLpXtmIXoRerK6HF0ApUIS66CnV4i43yKoAALv3M rMV7ecFiyzP/8mhC86T7MqwJLpUuEzY= X-Google-Smtp-Source: AOwi7QBDyVx3dTSEOSWrmNeczOmzRrkXM/YmiMtjYsPiYoCP7KUjOq8I0WTMY4R/jnIW2hlzG1Mu+g== X-Received: by 10.101.90.133 with SMTP id c5mr13240549pgt.441.1507663808784; Tue, 10 Oct 2017 12:30:08 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id r22sm19859788pfl.15.2017.10.10.12.30.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 12:30:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 12:29:45 -0700 Message-Id: <20171010193003.28857-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010193003.28857-1-richard.henderson@linaro.org> References: <20171010193003.28857-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 Subject: [Qemu-devel] [PULL v2 02/20] 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" 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 -= profile_getclock(), without later on getting += 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=0 0.0%) avg ops/TB 48.4 max=438 deleted ops/TB 8.54 avg temps/TB 32.31 max=38 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=0 0.0%) avg ops/TB 48.5 max=438 deleted ops/TB 8.56 avg temps/TB 32.31 max=38 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 Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Emilio G. Cota Signed-off-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 6b5d4bece2..b3bfe65059 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1300,7 +1300,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #ifdef CONFIG_PROFILER tcg_ctx.tb_count++; tcg_ctx.interm_time += profile_getclock() - ti; - tcg_ctx.code_time -= profile_getclock(); + ti = profile_getclock(); #endif /* ??? Overflow could be handled better here. In particular, we @@ -1318,7 +1318,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } #ifdef CONFIG_PROFILER - tcg_ctx.code_time += profile_getclock(); + tcg_ctx.code_time += profile_getclock() - ti; tcg_ctx.code_in_len += tb->size; tcg_ctx.code_out_len += gen_code_size; tcg_ctx.search_out_len += search_size;