From patchwork Tue Oct 10 00:55:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115313 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3168619qgn; Mon, 9 Oct 2017 18:01:05 -0700 (PDT) X-Received: by 10.200.38.3 with SMTP id u3mr17493681qtu.257.1507597265206; Mon, 09 Oct 2017 18:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507597265; cv=none; d=google.com; s=arc-20160816; b=WhvLMkuLzS6OYfMUkkXZ22QQEzIWS49lb5svAsKFpM2KoaN0LoSaVhKF6K9TSlyDz6 iLdfvVxviogaWaKKaCAQ2wX+mex/zucKuu+8L2mUKlz74bbMEWn2kfhfP+MnIc8Lk/03 So9lmP1dHfRu49EyyykiTbucQ+UNnReC5sDCrddaENoJ+94UVQYPeJZ3A2M4040LR7Pm kPGIPkE0E3fI4A/YyjYs2aSTCNBzgJiJuUNn/nszS7Xi1BonFlA97JV+73ITwa5srqzq KoBiC7FCJk+jxbrBO1+Xkd2z/3OixdBaS91KWXQKKnGfzjQNWhaxw242Ww992h5JoDVZ 5DDw== 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=KEdDFsu0dgIBq7A4xciD9aK2bU0/9nupg/7xALq4LtMYOvNkJ5kT+JCFYMAjNji5LQ 4tgcLGoqOkl63I5MIngnoWL7S3+LGhjBk9ESrTWDsdG1wuUV3y/6nnE9i5CZEMVNr6J5 r+9MS1uA4ZCkCNaGK6Y4/1xsvY0Ivl+WMfkQ3tKSckqUgaWdJllYRCpdAOAi3dOKpTkq yIJaGybe+ulWJgBuVwwDP0i0mr0urgy4LamWResMTomRW8dlVLH5e5jRs4SNsUqDEizu uWcYKcR+SC82qyqVgb61VmtlnnbNa6MnSLuZcIyEoYNOdMCSvay4vWxSqRxSJ9FLgGLx 4HGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kp1BUMNE; 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 l66si3485848qkh.507.2017.10.09.18.01.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Oct 2017 18:01:05 -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=kp1BUMNE; 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]:60502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1ius-0005dH-Rm for patch@linaro.org; Mon, 09 Oct 2017 21:01:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1iq8-00029y-Ey for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1iq7-0004H9-7u for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:08 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:43661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1iq7-0004GZ-2U for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:07 -0400 Received: by mail-pf0-x236.google.com with SMTP id d2so12282526pfh.0 for ; Mon, 09 Oct 2017 17:56:06 -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=kp1BUMNE9i/d/XDGrsyr2iovJEuv2Y0dIw45muA98IwZt54z4nWywcE9j+Wcw3cogj HRF7duWiEVvEqHvZJoQxlEKCNqjiyfEkEimYYf198r6U5A9L05Zh57AM1WEToHq6J0Bs huLXBMQK/vz4qDphcJF7ScV+T6l5xnKtRh/R8= 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=aofAXop6s9LEr/bJmLzY2K4P+wOhSlMGEtMhtPnge9B0qIz9MsHZVwUMYdoPeKXDE0 JZV8cKaDy2645TnEQYAFwDwgLNM3pqDqh4Fr5cBBBNBfuflBv8TPe1sNTJezwRoXccDi YtEnLj6qIjgHI4xfMf0ya0QEwBJT1u1tahvn5sfPaY59SKDqEUoGABdJxbGYlkn186HP CcQJ+qUcwH2ItXP0+Nr7GnKw0W4AsYtP73KrK5SsNc0McyAr1BVhN5V8fcIYnA4EsCre uZLnEMkKkaEDj1EsQRl6Vk+hnw4d/4sHAeA87yRlIM8PA7FtrBMAYp1FbOE41ZQfqcHY GpwA== X-Gm-Message-State: AMCzsaV1Do0+Ej2buHOe1L+bzGcl6vuEqceH/VY2sFriRqqk3VTUjOKg Mt5VktLZsFL6riAMzbhu+mMv4pCMxjo= X-Google-Smtp-Source: AOwi7QAyPH4HiIH4oaUVFMKa7kiq6nzVOD6cn0zGWm7W4c1HJt4CI35/WL4LeJAtroDv8LPLVk4SjA== X-Received: by 10.98.26.203 with SMTP id a194mr8692474pfa.113.1507596965728; Mon, 09 Oct 2017 17:56:05 -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 n19sm17121368pfj.52.2017.10.09.17.56.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 17:56:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 17:55:39 -0700 Message-Id: <20171010005600.28735-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010005600.28735-1-richard.henderson@linaro.org> References: <20171010005600.28735-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::236 Subject: [Qemu-devel] [PULL 02/23] 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;