From patchwork Mon Aug 3 09:14:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 51849 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 509EB229FD for ; Mon, 3 Aug 2015 09:16:54 +0000 (UTC) Received: by lbbyj8 with SMTP id yj8sf22656659lbb.3 for ; Mon, 03 Aug 2015 02:16:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=w/5386+OjfX4GHNF/VHsixP336JSAx/RVWMWnvoRd+c=; b=KMNSm7aMucOkbrVnOtcD5fRuumbTbTFfUnuWVIitbsXiLglF2HQvCBz6OrqlnoB0f4 YmyW9wbltLa8lruFOjtJ0qxVmMTjNQIghYvkcTcCTBcWEEvHtpMezd9r6eeGYS/VeIA4 CYLa3atcFVxSBUizJVrrQmXxe6IeUyWYI36pBC9EV01V/HZRV7a0AnJeVx0StOL8zSeZ bVu+T73JnrzpajvyuOUjNuzoglJ8bZYXj2kvnVr8K84IhdyvfvYLzkNRkw870Kmzg2od wjKtyfywaJwj7Vl46rIInKsrvVwR4BtpYScmCn0sCZ5Xs+Gus/6+CNy3bUgSXIZmc/aZ ffiA== X-Gm-Message-State: ALoCoQklKCS8o2SAtK6sHe9WC4axWExVKVdQ2g0OdJPw0tbYVLuqcuvCKivoNB8rMJEVGRSd+jw6 X-Received: by 10.112.138.2 with SMTP id qm2mr5207098lbb.19.1438593413279; Mon, 03 Aug 2015 02:16:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.131 with SMTP id wq3ls454082lac.106.gmail; Mon, 03 Aug 2015 02:16:52 -0700 (PDT) X-Received: by 10.112.144.69 with SMTP id sk5mr15834467lbb.6.1438593412855; Mon, 03 Aug 2015 02:16:52 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id qd10si4874297lbb.77.2015.08.03.02.16.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:16:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbqc9 with SMTP id c9so48993175lbq.1 for ; Mon, 03 Aug 2015 02:16:52 -0700 (PDT) X-Received: by 10.152.207.76 with SMTP id lu12mr15651011lac.29.1438593412710; Mon, 03 Aug 2015 02:16:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1754142lba; Mon, 3 Aug 2015 02:16:51 -0700 (PDT) X-Received: by 10.50.103.73 with SMTP id fu9mr20942300igb.46.1438593411143; Mon, 03 Aug 2015 02:16:51 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id ig14si5405357igb.49.2015.08.03.02.16.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Aug 2015 02:16:51 -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; Received: from localhost ([::1]:58176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBrV-00070i-V5 for patch@linaro.org; Mon, 03 Aug 2015 05:16:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpv-0005Qz-Ff for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMBpr-0003LI-Sf for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:11 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:38624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMBpr-0003Kd-Jx for qemu-devel@nongnu.org; Mon, 03 Aug 2015 05:15:07 -0400 Received: by wibxm9 with SMTP id xm9so105251629wib.1 for ; Mon, 03 Aug 2015 02:15:07 -0700 (PDT) X-Received: by 10.194.236.161 with SMTP id uv1mr34078880wjc.158.1438593307100; Mon, 03 Aug 2015 02:15:07 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q19sm12519557wik.16.2015.08.03.02.15.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 02:15:04 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 880693E0805; Mon, 3 Aug 2015 10:15:00 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2015 10:14:45 +0100 Message-Id: <1438593291-27109-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> References: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.169 Cc: Peter Maydell , qemu-trivial@nongnu.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v4 05/11] qemu-log: Improve the "exec" TB execution logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell Improve the TB execution logging so that it is easier to identify what is happening from trace logs: * move the "Trace" logging of executed TBs into cpu_tb_exec() so that it is emitted if and only if we actually execute a TB, and for consistency for the CPU state logging * log when we link two TBs together via tb_add_jump() * log when cpu_tb_exec() returns early from a chain of TBs The new style logging looks like this: Trace 0x7fb7cc822ca0 [ffffffc0000dce00] Linking TBs 0x7fb7cc822ca0 [ffffffc0000dce00] index 0 -> 0x7fb7cc823110 [ffffffc0000dce10] Trace 0x7fb7cc823110 [ffffffc0000dce10] Trace 0x7fb7cc823420 [ffffffc000302688] Trace 0x7fb7cc8234a0 [ffffffc000302698] Trace 0x7fb7cc823520 [ffffffc0003026a4] Trace 0x7fb7cc823560 [ffffffc0000dce44] Linking TBs 0x7fb7cc823560 [ffffffc0000dce44] index 1 -> 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc8235d0 [ffffffc0000dce70] Abandoned execution of TB chain before 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc822fd0 [ffffffc0000dd52c] Signed-off-by: Peter Maydell Signed-off-by: Alex Bennée [AJB: reword patch title] --- cpu-exec.c | 20 +++++++++++--------- include/exec/exec-all.h | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 75694f3..a039f1a 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -175,10 +175,14 @@ void cpu_reload_memory_map(CPUState *cpu) #endif /* Execute a TB, and fix up the CPU state afterwards if necessary */ -static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr) +static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) { CPUArchState *env = cpu->env_ptr; uintptr_t next_tb; + uint8_t *tb_ptr = itb->tc_ptr; + + qemu_log_mask(CPU_LOG_EXEC, "Trace %p [" TARGET_FMT_lx "] %s\n", + itb->tc_ptr, itb->pc, lookup_symbol(itb->pc)); #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { @@ -209,6 +213,10 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr) */ CPUClass *cc = CPU_GET_CLASS(cpu); TranslationBlock *tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK); + qemu_log_mask(CPU_LOG_EXEC, + "Abandoned execution of TB chain before %p [" + TARGET_FMT_lx "] %s\n", + itb->tc_ptr, itb->pc, lookup_symbol(itb->pc)); if (cc->synchronize_from_tb) { cc->synchronize_from_tb(cpu, tb); } else { @@ -247,7 +255,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, cpu->current_tb = tb; /* execute the generated code */ trace_exec_tb_nocache(tb, tb->pc); - cpu_tb_exec(cpu, tb->tc_ptr); + cpu_tb_exec(cpu, tb); cpu->current_tb = NULL; tb_phys_invalidate(tb, -1); tb_free(tb); @@ -356,7 +364,6 @@ int cpu_exec(CPUState *cpu) #endif int ret, interrupt_request; TranslationBlock *tb; - uint8_t *tc_ptr; uintptr_t next_tb; SyncClocks sc; @@ -491,10 +498,6 @@ int cpu_exec(CPUState *cpu) next_tb = 0; tcg_ctx.tb_ctx.tb_invalidated_flag = 0; } - if (qemu_loglevel_mask(CPU_LOG_EXEC)) { - qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n", - tb->tc_ptr, tb->pc, lookup_symbol(tb->pc)); - } /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct jump. */ @@ -513,9 +516,8 @@ int cpu_exec(CPUState *cpu) barrier(); if (likely(!cpu->exit_request)) { trace_exec_tb(tb, tb->pc); - tc_ptr = tb->tc_ptr; /* execute the generated code */ - next_tb = cpu_tb_exec(cpu, tc_ptr); + next_tb = cpu_tb_exec(cpu, tb); switch (next_tb & TB_EXIT_MASK) { case TB_EXIT_REQUESTED: /* Something asked us to stop executing diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 7ac8e7e..361d3d2 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -282,6 +282,9 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, { /* NOTE: this test is only needed for thread safety */ if (!tb->jmp_next[n]) { + qemu_log_mask(CPU_LOG_EXEC, "Linking TBs %p [" TARGET_FMT_lx + "] index %d -> %p [" TARGET_FMT_lx "]\n", + tb->tc_ptr, tb->pc, n, tb_next->tc_ptr, tb_next->pc); /* patch the native jump address */ tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr);