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: 115449 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4114428qgn; Tue, 10 Oct 2017 12:30:38 -0700 (PDT) X-Received: by 10.200.47.169 with SMTP id l38mr13544336qta.272.1507663838815; Tue, 10 Oct 2017 12:30:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507663838; cv=none; d=google.com; s=arc-20160816; b=aElyjHGXzviRJL7RyPOyZ6BkDgS1CXQmXbSro8L4N3HFfM2tn6UH9Ltl5Z5aes2iGL OdGxK/UQ4W74Yn4Tu0vIBtFg2HQmOPpc1Ns4MKRa+W7yasSbR9vG5li1pqv6oqR4HwRH bocwu1EK1QgG34neky+qVFlATfhE5xdP84ohXMW321XorI/zx12JGio4IqdVErjAAZnN LxgfChkipM4c1bO1W3i2Z6Wam14Dpt+YAUivk/zoGc7t39SSdK1rHYCha/ZKLvxVAQGg Zu9g0MVYvMhmYaDgF+lGVz/gHVMoWE4FQ4iuzUCAVRH0ElMh3ftgp+asJNWKstduwO/l kI/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=uWX8ltUJ41jzpP0mhxc6dOVFBO5YtrjkEa7vnTfdaYc=; b=whRJzgTuX+0tpNuDKUzK6EzK9kagFLwMavrETOOIOZwukNo8oZNxU6srNtBzUwyEE0 xy691UDre0fnJxkGoFxS1VB8rJ61/KgbAVtzk8GGg5lYlnN0Dg8pElc9ZN1csgNBZuRQ C6DINwTqQVrmVpLan1pyzfKM70vbhBH1M8zYT9LcRbnp42OAGqCBtmjtpP/JsdhY0unR 7d9S7HyXtEPnRyDCZWpQ0YtzdXkeXrjyWaAZGiVOLbFG7EZWdGyGnIhUWTnPRQMgOfhw rP2haiYGFPXzkKbtsj5QwELaKpy0yF4bFLWqLAiwYckrgu2mO48Now/AZAJ89L9wHtGa JpZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hNLSzppT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c3si4001746qtj.15.2017.10.10.12.30.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Oct 2017 12:30:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hNLSzppT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20Ee-0000X7-MH for patch@linaro.org; Tue, 10 Oct 2017 15:30:36 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.13.6 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;