From patchwork Wed Dec 15 14:04:54 2021 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: 524280 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp407638imb; Wed, 15 Dec 2021 06:42:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw82qdm8BhpNvGsQ7YLcVxs933Tvc6iPXXFl8+6UKGrjobgRUsDq/q7FnArzYQqAo8Ve4l X-Received: by 2002:a25:7613:: with SMTP id r19mr6479243ybc.498.1639579333726; Wed, 15 Dec 2021 06:42:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639579333; cv=none; d=google.com; s=arc-20160816; b=IQJgvD2ggCWKzTyi6HXpgE8KB8JaUmvGyI2+60mGzLxMdI5pXDDFEz2a6iP5s8a0/u U7w1UFsGi3KBQdYGxN2fdOa7PrOd801HFSeL/0KwNzKSAbxFocTSq2ldKDbgZl6qUy55 HtkD9guVEQ/ANo7lhb0yuC8iXcK7BIvtwU6zjDedSkfPnr98vKOuRPKoq3RpYknSSK7i aP6fiuir4tBKsrebfo39/i2HoIuuyKPGxBUlzbjKu8/PbgTRjTFBspPGmyPyk7SD+VmW ROL0Lq3Xh00/YnGt6rrRgJxuhWGbdA9wyPhjhvmnfU5cKD7bZWWWjHgWz1dlxBzVgAxx 0LUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=b6i02MVLehWsp7syQISC50HODgK5GX+9SoKqQ9/2sEU=; b=uLIFgT7iYTA8Le5+N9eqjE/5gI9MXLcFVNAMouBF97dhsymsj9UbIFjHxY7OAomJgJ Egb+YqWcDYrjcgcDf2SzILFaOIPvknr6LbnkgtQFmKDAl2weIeIPnVslv8QahXaibw4Y iQMNuQfwxj8MHxR85YXN7zK7LLitxdZ6GhPr8VRrqpEgQCAb3er2hIWFkgvkk+pYKbju 9X6SWR9l7lK3Z2VpgWeLlQRaRP+qGOKHPBBoHhs2ujnEjCyz9ld2KkchFyPK4jEScQfR QzA4Udh1iwR+z19aaw8XTGQA2rsDZ+844sqjS3dts4QgY5J1ga2a9BReMfMtQEEFHneP U7JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KNlV1VIy; 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=fail (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 g17si2256193ybc.401.2021.12.15.06.42.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Dec 2021 06:42:13 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=KNlV1VIy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxVTs-00008P-7l for patch@linaro.org; Wed, 15 Dec 2021 09:42:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxUuG-0004rs-Dd for qemu-devel@nongnu.org; Wed, 15 Dec 2021 09:05:21 -0500 Received: from [2a00:1450:4864:20::429] (port=39642 helo=mail-wr1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxUuD-0001yJ-0Q for qemu-devel@nongnu.org; Wed, 15 Dec 2021 09:05:19 -0500 Received: by mail-wr1-x429.google.com with SMTP id a18so38422887wrn.6 for ; Wed, 15 Dec 2021 06:05:12 -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:mime-version :content-transfer-encoding; bh=b6i02MVLehWsp7syQISC50HODgK5GX+9SoKqQ9/2sEU=; b=KNlV1VIyz/hcjcWK44TfMpzQd4lGMygSpcUMHMvoaWR+qitLg35us+OAzEAzk6eZIv fWmjgODiX8fCRPyCxKCiUpkppm7LIta/sIJQ7LKuNVMHDGLDRrQcqCy3TDLjQRJZPqvZ zGlwC7R6foNwSQI/qbAVhCZmBci+eoLmBJHBYHXFjrNrEcO3j3iFOm0G0JXfZZROs1ii s4zdKHZjRVeMbTnA9OFAoBz9eAdtCk1o0Nuaox7Aona9o7KNsDurTf5zkNE1LVpJ8oh4 ktlWF2rFpcZKMkhbrkqHrA/6v9BLTg6fNPwxcYEkJuDGWsjlQksSC86gbGCjsoLOynMt YgpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b6i02MVLehWsp7syQISC50HODgK5GX+9SoKqQ9/2sEU=; b=RDvEDkdEjxTArUNW/mrCDDQmtChsf83utqvVa6OXj2k5npVP6vV1W8rzrwEMjjH+GF ZlzFag7JfDDQ50uUA4JFkxlEgCSkDforhTgmDnsy9oQaIfDYoH6uCq7kVRVndBl3RJlg NJhVVJB3mf0SlYW4UubqQc8I0P9I28uTdA6XclUWuS+A8fDNKVa1TpqQyZTzKoabbdLk 4v0INE9kkmq70r8e3XIWx+jWn0ny1gQLOXatieTCxeJF99EZtozFR3Tx/Q+5MjZ6ZzE+ Jd8ajwAvO2xFftjUjYsn9DgBgBRXYjkX9u9CAmoY3r9cHbMVTXsx26GxUNNO0tmz4Aee Q8zg== X-Gm-Message-State: AOAM533lWdcAqtGEF05j/SI/MzviSD1O5LSONfKnQEGGSKcJrcscbRv4 eYW/PiFCEv+eFlF/Pm/M9p+gqg== X-Received: by 2002:a5d:5646:: with SMTP id j6mr4344662wrw.401.1639577111219; Wed, 15 Dec 2021 06:05:11 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id j14sm1584077wrn.88.2021.12.15.06.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 06:05:09 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D7A1E1FF96; Wed, 15 Dec 2021 14:05:07 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3] monitor: move x-query-profile into accel/tcg to fix build Date: Wed, 15 Dec 2021 14:04:54 +0000 Message-Id: <20211215140454.1725364-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::429 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Eduardo Habkost , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As --enable-profiler isn't defended in CI we missed this breakage. Move the qmp handler into accel/tcg so we have access to the helpers we need. While we are at it ensure we gate the feature on CONFIG_TCG. Signed-off-by: Alex Bennée Suggested-by: Daniel P. Berrangé Reported-by: Mark Cave-Ayland Fixes: 37087fde0e ("qapi: introduce x-query-profile QMP command") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/773 Reviewed-by: Daniel P. Berrangé Message-Id: <20211214195048.1438209-1-alex.bennee@linaro.org> Tested-by: Mark Cave-Ayland --- v3 - also add #ifdef CONFIG_TCG to hmp-commands-info.hx --- qapi/machine.json | 1 + accel/tcg/cpu-exec.c | 31 +++++++++++++++++++++++++++++++ monitor/qmp-cmds.c | 31 ------------------------------- hmp-commands-info.hx | 2 ++ 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 067e3f5378..0c9f24a712 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1492,6 +1492,7 @@ ## { 'command': 'x-query-profile', 'returns': 'HumanReadableText', + 'if': 'CONFIG_TCG', 'features': [ 'unstable' ] } ## diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 409ec8c38c..8b4cd6c59d 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -1090,4 +1090,35 @@ HumanReadableText *qmp_x_query_opcount(Error **errp) return human_readable_text_from_str(buf); } +#ifdef CONFIG_PROFILER + +int64_t dev_time; + +HumanReadableText *qmp_x_query_profile(Error **errp) +{ + g_autoptr(GString) buf = g_string_new(""); + static int64_t last_cpu_exec_time; + int64_t cpu_exec_time; + int64_t delta; + + cpu_exec_time = tcg_cpu_exec_time(); + delta = cpu_exec_time - last_cpu_exec_time; + + g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n", + dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); + g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n", + delta, delta / (double)NANOSECONDS_PER_SECOND); + last_cpu_exec_time = cpu_exec_time; + dev_time = 0; + + return human_readable_text_from_str(buf); +} +#else +HumanReadableText *qmp_x_query_profile(Error **errp) +{ + error_setg(errp, "Internal profiler not compiled"); + return NULL; +} +#endif + #endif /* !CONFIG_USER_ONLY */ diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 343353e27a..be5e44c569 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -355,37 +355,6 @@ void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) } } -#ifdef CONFIG_PROFILER - -int64_t dev_time; - -HumanReadableText *qmp_x_query_profile(Error **errp) -{ - g_autoptr(GString) buf = g_string_new(""); - static int64_t last_cpu_exec_time; - int64_t cpu_exec_time; - int64_t delta; - - cpu_exec_time = tcg_cpu_exec_time(); - delta = cpu_exec_time - last_cpu_exec_time; - - g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n", - dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); - g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n", - delta, delta / (double)NANOSECONDS_PER_SECOND); - last_cpu_exec_time = cpu_exec_time; - dev_time = 0; - - return human_readable_text_from_str(buf); -} -#else -HumanReadableText *qmp_x_query_profile(Error **errp) -{ - error_setg(errp, "Internal profiler not compiled"); - return NULL; -} -#endif - static int qmp_x_query_rdma_foreach(Object *obj, void *opaque) { RdmaProvider *rdma; diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 407a1da800..e90f20a107 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -358,6 +358,7 @@ SRST Show host USB devices. ERST +#if defined(CONFIG_TCG) { .name = "profile", .args_type = "", @@ -365,6 +366,7 @@ ERST .help = "show profiling information", .cmd_info_hrt = qmp_x_query_profile, }, +#endif SRST ``info profile``