From patchwork Thu Feb 4 14:56:16 2016 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: 61190 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp505642lbl; Thu, 4 Feb 2016 06:59:17 -0800 (PST) X-Received: by 10.140.108.8 with SMTP id i8mr9650697qgf.83.1454597957242; Thu, 04 Feb 2016 06:59:17 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l62si10901234qhc.126.2016.02.04.06.59.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Feb 2016 06:59:17 -0800 (PST) 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; 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; dkim=fail header.i=@linaro.org Received: from localhost ([::1]:42225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLNM-0005Mq-PI for patch@linaro.org; Thu, 04 Feb 2016 09:59:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLKp-0001gg-MA for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRLKo-0001Ra-A0 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:39 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:36959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRLKn-0001RB-VR for qemu-devel@nongnu.org; Thu, 04 Feb 2016 09:56:38 -0500 Received: by mail-wm0-x230.google.com with SMTP id g62so8272498wme.0 for ; Thu, 04 Feb 2016 06:56:37 -0800 (PST) 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-type:content-transfer-encoding; bh=Cp5D6TZidYPxE/YKaWyj/o1xtzx6WXnq8lAF8BNbwXs=; b=FONqxzQCIPp7WvVazOrxxe/FPEazGGFCvoUms1Z3OwHHQxBR2pGxrxGuteC1y0kmWR teU15fHlSspx1MIsSvqoiLXAvXtZjoPHI9G9Fs6ZtrOimP5EzgbsIE5GwJsbnWAYo1Co 8I7JRi34eQEJDfdmtzXNRnQ2T4PhtJinQAdYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=Cp5D6TZidYPxE/YKaWyj/o1xtzx6WXnq8lAF8BNbwXs=; b=db+y3OYAaK2WOsYA3QCSJMZxFwHhHL+O2uUWr19S/M5k/ypFaog43S7IH5hMhScxE1 4C4pLWf+4trhoS9xXk1i7yQjtwY7lISbDg+5SU+CYrr5nWo2mR9h7lRtPgfYJUYgFBdO i7/Y39EHdmtpX4l+gtzxjNJU9aeGrlgFZGVHBujjQ/D5lnv4W7WHIuPhQpSZhhwfBFNv DcUgqG64mH3c/rpZXr4MxmsY4lWW4eZLg/drr3tRmCXxhxxUJTttvQ1hdICFTmSGAcef 2oChxnKRHFPWcIX/B/cMod7/aCHHgyf+2nm10PWg2F1fWjVVeWRDpOQNvbNwS6rDtZWs 1oig== X-Gm-Message-State: AG10YOSv58tM8fLQVXrSHWxeQZVMfrlvYbklBQNuj9PVyIeEeZ7A6/q1rM/fXJkXqcFJVunX X-Received: by 10.194.157.3 with SMTP id wi3mr8631258wjb.30.1454597797231; Thu, 04 Feb 2016 06:56:37 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w62sm26650048wmg.21.2016.02.04.06.56.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Feb 2016 06:56:32 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D4BAE3E0782; Thu, 4 Feb 2016 14:56:29 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2016 14:56:16 +0000 Message-Id: <1454597781-18115-5-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454597781-18115-1-git-send-email-alex.bennee@linaro.org> References: <1454597781-18115-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] X-Received-From: 2a00:1450:400c:c09::230 Cc: peter.maydell@linaro.org, Peter Crosthwaite , dgilbert@redhat.com, crosthwaitepeter@gmail.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v5 4/9] 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 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] Reviewed-by: Aurelien Jarno --- cpu-exec.c | 20 +++++++++++--------- include/exec/exec-all.h | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) -- 2.7.0 diff --git a/cpu-exec.c b/cpu-exec.c index c459364..8151e6f 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -132,10 +132,14 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu) #endif /* CONFIG USER ONLY */ /* 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)) { @@ -166,6 +170,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 { @@ -201,7 +209,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); @@ -343,7 +351,6 @@ int cpu_exec(CPUState *cpu) #endif int ret, interrupt_request; TranslationBlock *tb; - uint8_t *tc_ptr; uintptr_t next_tb; SyncClocks sc; @@ -499,10 +506,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. */ @@ -514,10 +517,9 @@ int cpu_exec(CPUState *cpu) tb_unlock(); if (likely(!cpu->exit_request)) { trace_exec_tb(tb, tb->pc); - tc_ptr = tb->tc_ptr; /* execute the generated code */ cpu->current_tb = tb; - next_tb = cpu_tb_exec(cpu, tc_ptr); + next_tb = cpu_tb_exec(cpu, tb); cpu->current_tb = NULL; switch (next_tb & TB_EXIT_MASK) { case TB_EXIT_REQUESTED: diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 05a151d..1823ee3 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -379,6 +379,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);