From patchwork Tue Oct 3 18:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 728808 Delivered-To: patch@linaro.org Received: by 2002:a5d:60c8:0:b0:31d:da82:a3b4 with SMTP id x8csp2285691wrt; Tue, 3 Oct 2023 11:32:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7pJl/4cza4s6L98iYwX+hm7p0YMXZ1mb0bIHZG1J7ON7truvM4ZqLJvtSyLNWuceIxlhj X-Received: by 2002:a25:c5c6:0:b0:d84:bf67:c775 with SMTP id v189-20020a25c5c6000000b00d84bf67c775mr97002ybe.17.1696357977289; Tue, 03 Oct 2023 11:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696357977; cv=none; d=google.com; s=arc-20160816; b=HeWXQqz+RTg4CnTpZ8KOvMmcO7zuGFuzJlluV0zFNgGu04jUI8GK1wjTzp5s+XrLJi 8S3AEYDUxrQgwWLKvkKKOwtQ8ThGJLu6oyro7bYMMLHFR2YpOzPKWHJqBzhUf2tz6JLf eP8NPnbn9iwfpLM4xFiw4ZvHlPQ/AiAoCNHpHhxrcxdT0MMOtA+G5X1x9thj/8rJWqHD 3qVZAf1+2tHsbniVf/4Na/i7uEKVr4I7IEb45CKZ6glSPiikzP4oSL57JFX0OzdL3Xyt D+kuumJAK9SfbhORy+/cCWyR+E99Ex9LwZIIf0oxjHvctenPbXii+EQALjY7lLEpiMVJ cx5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MD25jSGXV56D96OuAdfZq5dSUt2s3HFUz4HxD2v8rb0=; fh=Grk8ert1aVMPN1jf5/SpIQC06nonvH9hdZT9h94lZCY=; b=GqS11zdpPMmAxDhsqcS3Z5QdSw4ONKRihXJoZh7X0j1XWDJ/vsJ8Jvbqv+qwcn/YF5 GB9ncI/xsnyT9/DeLQ5epxEHr3vdjeO1kJiu/fHY24slqbX6iRvhLXrwVfeHoovpF00F ZxoHoGm/svGsRkG+dDnZIhaPvSDn2KqwghJ6J2fc3P2Hg66yB5WcnQK2FsL2mziHTcJn keI0t2iRq7rzDEPOEnQwbvCadE9r6naqd2RpQb71R6gEwDkIpV29aJf0eJ8f3ND38LiC Np6GhZs7jVSnvEiUdJ/Wx7FiOZY230XYZ7C3HgA+NOm0rExHsfa19K2d1WCrhfRYVOVH +TgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wH1VXlWC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g11-20020a0ce4cb000000b0065afd35c75dsi739552qvm.70.2023.10.03.11.32.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Oct 2023 11:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wH1VXlWC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnkAv-000877-Re; Tue, 03 Oct 2023 14:31:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnkAu-00086b-JK for qemu-devel@nongnu.org; Tue, 03 Oct 2023 14:31:16 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnkAp-0001gE-NL for qemu-devel@nongnu.org; Tue, 03 Oct 2023 14:31:16 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c3f97f2239so10080975ad.0 for ; Tue, 03 Oct 2023 11:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696357869; x=1696962669; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MD25jSGXV56D96OuAdfZq5dSUt2s3HFUz4HxD2v8rb0=; b=wH1VXlWCJ2Mh3egL1omTGdqNB29L5dbjwuAyNzwXOiu+8/OvOj772lWj9KdVkiT74P VisN9Ps4GKc0zyF2JyAW835QLj+A+JqU6CsW5lM53g848+vFOfDRZbXXyb5cvrZSqR7W cV9aS6Tjk2lnEA/btr6dbTt2nEJXeBfQbBL11SPWMJSZCQHYTe6XZ+ZChCAIegz2U3lK 4b6RAkct684yHvA0Zs8v2f/KypZBeiBnqQMhcOBdIgP0BjJxzEeurfW2Z55y2zym0lRc 6wrA7djQwqgtSHXnCGitROM2079/sher+7oKimsTZMTYu42Ekw4ciHIP3j/zUYGTFWw0 Ecgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696357869; x=1696962669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MD25jSGXV56D96OuAdfZq5dSUt2s3HFUz4HxD2v8rb0=; b=Pu1qUJC4UhN1OL1nMtI27NKF0K38Xbov13KwnpgSVHxRvtcJPy83URBVVc2NHxgec7 VgYeiGnu2AOGqsygA6K5NCXew3+FcNl1WiRFrQpCE7m46HNmjanar9FGNijs6p9PLOv/ 8W89KiCZqXv6aZ+rhd+b5gkn+LNfiQ2p9XtfwP33y5Di8HvdsGWizOUAGU7RVwtZ9e3I fpDP8oS6DdRtouadZor4b1lYDtqc0dtLJEQNNF9SJGpzNV2t1vNUAWAs6ZYbX3yuIbn+ kQ1soAyCNo5LQ9NIBNERpKnImtfu9GOYWE4ENbyBz7p2G2FOlWlJvxPSzOSVX8aPD0kF OscA== X-Gm-Message-State: AOJu0YwEguaWxmZeWSOEL5RmTwp93dVA6RdFRU0+7vUpb890WoVpjCey fdF2BT7h0WNShrNqOkMbCr3QN/qf9oNsf5e1Gag= X-Received: by 2002:a17:903:1c1:b0:1c0:c4be:62ca with SMTP id e1-20020a17090301c100b001c0c4be62camr417335plh.17.1696357869317; Tue, 03 Oct 2023 11:31:09 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id g7-20020a170902934700b001b7cbc5871csm1920432plp.53.2023.10.03.11.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 11:31:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: fei2.wu@intel.com, "Vanderson M . do Rosario" , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v17 10/16] util/log: Add -d tb_stats Date: Tue, 3 Oct 2023 11:30:52 -0700 Message-Id: <20231003183058.1639121-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003183058.1639121-1-richard.henderson@linaro.org> References: <20231003183058.1639121-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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: Fei Wu Enable TBStatistics collection from startup. Signed-off-by: Vanderson M. do Rosario Signed-off-by: Alex Bennée Signed-off-by: Fei Wu [rth: Change "tb_stats_foo" to "tb_stats:foo"] Signed-off-by: Richard Henderson --- stubs/tb-stats.c | 16 ++++++++++++++++ util/log.c | 36 +++++++++++++++++++++++++++++++----- stubs/meson.build | 1 + 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 stubs/tb-stats.c diff --git a/stubs/tb-stats.c b/stubs/tb-stats.c new file mode 100644 index 0000000000..ceaa1622ce --- /dev/null +++ b/stubs/tb-stats.c @@ -0,0 +1,16 @@ +/* + * TB Stats Stubs + * + * Copyright (c) 2019 + * Written by Alex Bennée + * + * This code is licensed under the GNU GPL v2, or later. + */ + + +#include "qemu/osdep.h" +#include "tcg/tb-stats.h" + +void tb_stats_init(uint32_t flags) +{ +} diff --git a/util/log.c b/util/log.c index b5f08db202..0cb987fb74 100644 --- a/util/log.c +++ b/util/log.c @@ -30,6 +30,9 @@ #ifdef CONFIG_LINUX #include #endif +#ifdef CONFIG_TCG +#include "tcg/tb-stats.h" +#endif typedef struct RCUCloseFILE { @@ -509,22 +512,41 @@ int qemu_str_to_log_mask(const char *str, Error **errp) char **tmp; for (tmp = parts; tmp && *tmp; tmp++) { - if (g_str_equal(*tmp, "all")) { + char *t = *tmp; + + if (g_str_equal(t, "all")) { for (item = qemu_log_items; item->mask != 0; item++) { mask |= item->mask; } #ifdef CONFIG_TRACE_LOG - } else if (g_str_has_prefix(*tmp, "trace:") && (*tmp)[6] != '\0') { - trace_enable_events((*tmp) + 6); + } else if (g_str_has_prefix(t, "trace:") && t[6] != '\0') { + trace_enable_events(t + 6); mask |= LOG_TRACE; +#endif +#ifdef CONFIG_TCG + } else if (g_str_has_prefix(t, "tb_stats:") && t[9] != '\0') { + int flags = TB_STATS_NONE; + char *v = t + 9; + + if (g_str_equal(v, "all")) { + flags = TB_STATS_ALL; + } else if (g_str_equal(v, "jit")) { + flags = TB_STATS_JIT; + } else if (g_str_equal(v, "exec")) { + flags = TB_STATS_EXEC; + } else { + error_setg(errp, "Invalid -d option \"%s\"", t); + goto error; + } + tb_stats_init(flags); #endif } else { for (item = qemu_log_items; item->mask != 0; item++) { - if (g_str_equal(*tmp, item->name)) { + if (g_str_equal(t, item->name)) { goto found; } } - error_setg(errp, "Invalid -d option \"%s\"", *tmp); + error_setg(errp, "Invalid -d option \"%s\"", t); goto error; found: mask |= item->mask; @@ -546,6 +568,10 @@ void qemu_print_log_usage(FILE *f) for (item = qemu_log_items; item->mask != 0; item++) { fprintf(f, "%-15s %s\n", item->name, item->help); } +#ifdef CONFIG_TCG + fprintf(f, "tb_stats:WHICH enable translation block statistics" + " (all, exec, jit)\n"); +#endif #ifdef CONFIG_TRACE_LOG fprintf(f, "trace:PATTERN enable trace events\n"); fprintf(f, "\nUse \"-d trace:help\" to get a list of trace events.\n\n"); diff --git a/stubs/meson.build b/stubs/meson.build index ef6e39a64d..37ca25ea01 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -65,4 +65,5 @@ else stub_ss.add(files('qdev.c')) endif stub_ss.add(files('semihost-all.c')) +stub_ss.add(files('tb-stats.c')) stub_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_false: files('vfio-user-obj.c'))