From patchwork Fri Mar 28 16:43:23 2014 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: 27361 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67C3C20545 for ; Fri, 28 Mar 2014 16:49:24 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id dc16sf1209173qab.11 for ; Fri, 28 Mar 2014 09:49:24 -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: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:content-type :content-transfer-encoding; bh=XMk3LeXvbC0bTsSPNSj7AcXIrDBRy6ZZIxw68dqmT7c=; b=ddi/Qd3K5WhotGDty2GNUjpYGTS3m729BxmrJO24jTi0j+RpMhGF5Bny0lXj98cYbQ LvPqfnweAimuKTO5eVKSg5cIIXPyQ8AKr6+rV2i2vT67vIXsSEwb3iFPhoD3QyV1nMlk oUeeLWY9XeFrQ+j56L1rTlb+FZuY/Hc7YBSo2drpWYmNGfzaNxrSmRG3kGs/dE7Z1MOH 0UzO/6YAY+KNkY8AobmZ5Er+Fsgf1BZ+pzFkbR5xGAQnbXS8XFT/VgJah0zU/k5NjCNZ eybiCrSEuHgSmzAB7syvVR9PxNMVf+MF9ZjP+8Rad2tfbhESphCu9gLmXW0diCvvIvzB wnTg== X-Gm-Message-State: ALoCoQnBrSJS43aShG2FV5DrKIyXQ9pcAsaswmRu3hsiLuwD9vrzFxP9zalVCcwPt3yNOBc9q0xE X-Received: by 10.58.178.137 with SMTP id cy9mr2538848vec.34.1396025364179; Fri, 28 Mar 2014 09:49:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.165 with SMTP id 34ls1759718qgb.30.gmail; Fri, 28 Mar 2014 09:49:24 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr1163313vdb.30.1396025364028; Fri, 28 Mar 2014 09:49:24 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id rx10si1331340vdc.168.2014.03.28.09.49.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:49:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id db11so2777288veb.21 for ; Fri, 28 Mar 2014 09:49:24 -0700 (PDT) X-Received: by 10.58.57.42 with SMTP id f10mr8085246veq.1.1396025363929; Fri, 28 Mar 2014 09:49:23 -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.220.12.8 with SMTP id v8csp23454vcv; Fri, 28 Mar 2014 09:49:23 -0700 (PDT) X-Received: by 10.224.167.12 with SMTP id o12mr3717397qay.77.1396025363500; Fri, 28 Mar 2014 09:49:23 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k1si2772989qaf.235.2014.03.28.09.49.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:49:23 -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]:34999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZy7-0005qx-4T for patch@linaro.org; Fri, 28 Mar 2014 12:49:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsU-00077C-Kt for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTZsP-0002jX-Bq for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:34 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:56331 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsO-0002jH-V1 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:29 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1WTZsn-0004ll-Vl; Fri, 28 Mar 2014 17:43:54 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 28 Mar 2014 16:43:23 +0000 Message-Id: <1396025007-27592-4-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> References: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Qemu-devel] [PATCH v2 3/7] 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=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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] diff --git a/cpu-exec.c b/cpu-exec.c index 0914d3c..40bdf88 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -43,10 +43,14 @@ void cpu_resume_from_signal(CPUState *cpu, void *puc) #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)) { @@ -72,6 +76,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 { @@ -105,7 +113,7 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles, max_cycles); cpu->current_tb = tb; /* execute the generated code */ - cpu_tb_exec(cpu, tb->tc_ptr); + cpu_tb_exec(cpu, tb); cpu->current_tb = NULL; tb_phys_invalidate(tb, -1); tb_free(tb); @@ -225,7 +233,6 @@ int cpu_exec(CPUArchState *env) #endif int ret, interrupt_request; TranslationBlock *tb; - uint8_t *tc_ptr; uintptr_t next_tb; if (cpu->halted) { @@ -610,10 +617,6 @@ int cpu_exec(CPUArchState *env) 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. */ @@ -630,9 +633,8 @@ int cpu_exec(CPUArchState *env) cpu->current_tb = tb; barrier(); if (likely(!cpu->exit_request)) { - 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 f9ac332..64b8afd 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -288,6 +288,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);