From nobody Tue Nov 11 14:08:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563584691; cv=none; d=zoho.com; s=zohoarc; b=Rs91QLOVVMbIgVF0DJZS2lnfq8XDEbYnJcTTzL341y+LVeWin/9IFsTLWmrC4Vh8GHLZ6qnuNFcwqD7QV4OvJ38finaYxR5aL5c9h7c2eFtaE3Tf8e1PA9kfDNPLZENmM6pvF6eiuJnHr1ZKC1G4d/3mka4x3irBDB6caoZJCbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563584691; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Q+nw72rF9g/bpUICpo+ScG/tVrJDwS+qDXPM6jCFUOg=; b=nRlk1ty00TiinOCaRiXEdZKrX103xIUUc4aIBL+Z+HjV87CcSjxLPk10IefMo500vbpbUoPLu7IBeH8Xsq1CEOByk3waF9+UQRiB265eQ62grAnyRTOFexcbwmZIRArR8+3nR+Fu2K8D42fhhEmt7l60LMTejsT/HDHTe9fIpMs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563584691047297.1232672969476; Fri, 19 Jul 2019 18:04:51 -0700 (PDT) Received: from localhost ([::1]:49050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hodnu-00048L-4a for importer@patchew.org; Fri, 19 Jul 2019 21:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39999) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hodmV-0006Ya-Ue for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:03:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hodmU-0006Ic-Rz for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:03:23 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:43193) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hodmU-0006IP-OF for qemu-devel@nongnu.org; Fri, 19 Jul 2019 21:03:22 -0400 Received: by mail-qk1-x744.google.com with SMTP id m14so24563673qka.10 for ; Fri, 19 Jul 2019 18:03:22 -0700 (PDT) Received: from vanderson-lmcad.domain.name ([177.137.96.41]) by smtp.googlemail.com with ESMTPSA id g10sm13405115qki.37.2019.07.19.18.03.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 18:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q+nw72rF9g/bpUICpo+ScG/tVrJDwS+qDXPM6jCFUOg=; b=pu4JJLFTzifIMuTTYOLgZe6JBQoMEIFLAL8GhQWgrqYmzQ6Yp/SudlO/kkHLaaE2ld XtUO0rnT2xCDv3P9JPCJ3HWGEsIq1476BNQLIjJMX3/AzsGYBMyJ8Dsl//xt8AfhLEE9 cSqRP8wd1IRa8rfnmy4X+kA03Ped/4ciEI8ix2E4RbwvYUTfmVI9RVt9aXZBZfollIRJ ehrDuK+46ztta80RckTuZ8ClQMKVZpoTophbKXqQ9Am1GMLm0dpMCHUD46GUi/oGL8VF tz5UJpBqOdiUQfUMHG3V9SYyje0tTaMZ1fm5lTKdtN0RBDzM2i3cawtlpv6/LtxIAe6f TkNA== 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=Q+nw72rF9g/bpUICpo+ScG/tVrJDwS+qDXPM6jCFUOg=; b=VR7Mow+3P8AMKeBV4MMMAdi9HuZRehZ+pcmm3ggOqURyoWz87vjCANBdW0bq0iKnxB D59C2YGgjEjN2ZvjovA1exiBQ+/Z/u+8HZTpZVUpmOfCqyywHix7iBo6IN0RTLFlWiKZ +NoVmNkFNgTaSk4zXClXyqzkPl26ZqggUUnuiAjL5nMMSrKf4fow3AhdOwL6ZSvZeVMy KnebuxeAlqHOtu4Df5GWFbgdnTA8DRmXD3e4Cdk+rRbH9966qZAZp3Uh9tIchQFNA9VA TeFiV3eZuNvsIWEu6CGR/uXalGLxw2aZOCzw7QmTSykRVqWzNjgVfAFu/Hz3o15+VbcJ Rbpg== X-Gm-Message-State: APjAAAXaOaSgWFhDZQEVnCvw1iVuMVaumxpvnaZoU6EoDBOXDgfabuKO /Os2R5zWPik9xG+wSBwk1nKzmw/Z X-Google-Smtp-Source: APXvYqyvqf90yULGN33aAIM7hno/P27dbpH4fwtD6WZ+40A1xNgll20VDEjQXJy3XSU3DqVcZ1zPzA== X-Received: by 2002:a37:6c8:: with SMTP id 191mr39277192qkg.102.1563584602037; Fri, 19 Jul 2019 18:03:22 -0700 (PDT) From: vandersonmr To: qemu-devel@nongnu.org Date: Fri, 19 Jul 2019 22:02:33 -0300 Message-Id: <20190720010235.32444-6-vandersonmr2@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190720010235.32444-1-vandersonmr2@gmail.com> References: <20190720010235.32444-1-vandersonmr2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::744 Subject: [Qemu-devel] [PATCH v4 5/7] log: adding -d tb_stats to control tbstats X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vandersonmr Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Adding -d tb_stats:[limit:[all|jit|exec]] to control TBStatistics collection. "limit" is used to limit the number of TBStats in the linux-user dump. [all|jit|exec] control the profilling level used by the TBStats: all, only jit stats or only execution count stats. Signed-off-by: Vanderson M. do Rosario --- include/qemu/log.h | 1 + util/log.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/qemu/log.h b/include/qemu/log.h index 8cdfc268ca..93642603e5 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ #define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_FPU (1 << 17) +#define CPU_LOG_TB_STATS (1 << 18) =20 /* Lock output for a series of related logs. Since this is not needed * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we diff --git a/util/log.c b/util/log.c index f81653d712..8109d19afb 100644 --- a/util/log.c +++ b/util/log.c @@ -30,6 +30,7 @@ FILE *qemu_logfile; int qemu_loglevel; static int log_append =3D 0; static GArray *debug_regions; +int32_t max_num_hot_tbs_to_dump; =20 /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) @@ -273,6 +274,8 @@ const QEMULogItem qemu_log_items[] =3D { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, + { CPU_LOG_TB_STATS, "tb_stats[:limit:(all,jit,exec)]", + "show TBs statistics (until given a limit) ordered by their hotness.= \n" }, { 0, NULL, NULL }, }; =20 @@ -294,6 +297,37 @@ int qemu_str_to_log_mask(const char *str) trace_enable_events((*tmp) + 6); mask |=3D LOG_TRACE; #endif + } else if (g_str_has_prefix(*tmp, "tb_stats")) { + if (g_str_has_prefix(*tmp, "tb_stats:") && (*tmp)[9] !=3D '\0'= ) { + + if (!g_ascii_isdigit(*((*tmp) + 9))) { + fprintf(stderr, + "should be a number follow by [all|jit|exec], = as tb_stats:10:all\n"); + exit(1); + } + /* get limit */ + max_num_hot_tbs_to_dump =3D atoi((*tmp) + 9); + + /* get profilling level */ + char *s =3D (*tmp) + 9; + while (*s !=3D '\0') { + if (*s++ =3D=3D ':') { + break; + } + } + if (g_str_equal(s, "jit") =3D=3D 0) { + set_default_tbstats_flag(TB_JIT_STATS); + } else if (g_str_equal(s, "exec") =3D=3D 0) { + set_default_tbstats_flag(TB_EXEC_STATS); + } else { + set_default_tbstats_flag(TB_JIT_STATS | TB_EXEC_STATS); + } + } else { + set_default_tbstats_flag(TB_JIT_STATS | TB_EXEC_STATS); + } + + mask |=3D CPU_LOG_TB_STATS; + enable_collect_tb_stats(); } else { for (item =3D qemu_log_items; item->mask !=3D 0; item++) { if (g_str_equal(*tmp, item->name)) { --=20 2.22.0