From patchwork Wed Jan 12 11:27:13 2022 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: 531576 Delivered-To: patch@linaro.org Received: by 2002:a5d:4010:0:0:0:0:0 with SMTP id n16csp1493311wrp; Wed, 12 Jan 2022 03:49:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWf1siWShK7OnhUokGdYJgSvuvh1gvVAY7GbcX+ICyV5fc7zs1esLE1I/h7Ki1Y7ZR1HP6 X-Received: by 2002:a05:6902:1209:: with SMTP id s9mr12100870ybu.48.1641988173968; Wed, 12 Jan 2022 03:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641988173; cv=none; d=google.com; s=arc-20160816; b=ymmXSTF0gJPkEcRIE0i2+hNCZFd8Qhup98RL9K4AjanpXOY5xEumkMqkYoFYpWLb7q 5GOtvpD84MJjqtRK01go5sTzMp6oT5GqKPKiFQuJ32FypKc8AxL2FuFRCo67N1xt7t3d tyfGbhmafhXSYcFod1Hfzt+DPQjtlBDKEhXZS0eAd5ZoNa0vdsfnS9hIlPIfpvXsWUFz WbOELAQ66Z0OjORX77R0jEh6L7rJo94dfFqXXsO7qV6EdJz722lTxsnao6p88MfqApJd b4dcPulKtbHwyqbXZD2omLQSNHGHBTIPyvQ35TVusKfkczF3dLbPShZQLOVah4PW8OIA r0Cg== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0myPl6OHjV6t6kuNhHnigg5iN4dMo4gSfiEskPIfieA=; b=UYUakDy3rSOWHUP8dCmpPdfZ6m953iCoSrm8d7bVD3jNvdb3YhJTi14tInimyWC++T 6/eJGOV8xP9hLbvQv1Iywyq5aQ6iwAwAEAUFebNrF76cLMZ3bqP3pE+u+wN9d7drJoYF EU5e/4lix4FwAJ6d5pZ5wJo6SmIw86h8dpCOeg1dEogQ1neKK5zUmqUyqIvHr2WF4cjZ M2myg8C/6qmkpO0CjtuFNMv6jdA+XhZ87jggT2xGDS+2Mu3cXDojSxYOnb0zKA0vbj/C vat0VgA6hfsjELj88AeToz/6xYJGAPSrNGDjdDx7bAHqdIL2Z66Rdyw/imwz9qJLtphI qQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jIsj2kyp; 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 y9si9666954ybr.160.2022.01.12.03.49.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Jan 2022 03:49:33 -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=jIsj2kyp; 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]:47548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7c8D-0006td-9n for patch@linaro.org; Wed, 12 Jan 2022 06:49:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7bvL-0007G8-EJ for qemu-devel@nongnu.org; Wed, 12 Jan 2022 06:36:15 -0500 Received: from [2a00:1450:4864:20::52b] (port=35577 helo=mail-ed1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7bvJ-0004j0-Ay for qemu-devel@nongnu.org; Wed, 12 Jan 2022 06:36:15 -0500 Received: by mail-ed1-x52b.google.com with SMTP id q25so8789604edb.2 for ; Wed, 12 Jan 2022 03:36: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=0myPl6OHjV6t6kuNhHnigg5iN4dMo4gSfiEskPIfieA=; b=jIsj2kyp8DeiLAQooIjy42T7P0KY7QuG7pyaqWJlwfBUURNzoATBz/sfbDx0otQm91 OF1nmieMi2qEhaQcBg8vhsDnPMjP67+hJK6F7Lo11b4lkp5lws8J4tW3Lu2N+abw4swz Lm43JO6TAzXooKXzFfS+UQd+OHt9uOhEgqkUhLduNDF2ryu8UYzVwYi9IPoX7gjAa2Nl FycOBK8i6iwEwZzdB8KkPAToKOvIrf/KHMCLE70aLKEVFBe56OOA4ORRh7Lr7l84Wg8V mDnS0tHIeQtmFL5j625gMIKInd142lSChq90b5hD7V0SM59YTIHLUIBS/kIohAWGocxq 961w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=0myPl6OHjV6t6kuNhHnigg5iN4dMo4gSfiEskPIfieA=; b=LeYSW4rtqG4+QKF+zPHpKqF1WIMtelxxRUHQ53EBgOfxbJToKDr2yfzd5MgWmHWenm Xd0iyBVfZo3UxvIE4ff6G2pPTZlZzF+ztNaxYoWLWFo//2qNeeuhFxINd9fwzUIoxVYk Y1JDCCL2YqV3uwgzOS9kebbOHCpxiXXwbOah0ij2y8j1axIhk5xT27I3HfvTwoYgXiab 82mqz2SQNqFk1PfxuRQ8t1prQHM6hEHkqk8iHJPKPWX6Rj5VgnpZYOffOwKkGni3YmSR aeHqSaqmiNr8hAuArFHefLNywlPc3Yrzri4g9ckAd3+hiN/NGCr1sJjR82TtUkrBuGen allA== X-Gm-Message-State: AOAM533p2AKPW/ONJNM2dctcsUTZEyew5sF7sYW1X2hFyRSXcNxbOXpp GFc2CupxpLW3DVCIJfIQtsL3xw== X-Received: by 2002:a17:907:212c:: with SMTP id qo12mr2503707ejb.713.1641987371933; Wed, 12 Jan 2022 03:36:11 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r12sm417799ejb.32.2022.01.12.03.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 03:36:10 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 545651FFCE; Wed, 12 Jan 2022 11:27:24 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 22/31] monitor: move x-query-profile into accel/tcg to fix build Date: Wed, 12 Jan 2022 11:27:13 +0000 Message-Id: <20220112112722.3641051-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220112112722.3641051-1-alex.bennee@linaro.org> References: <20220112112722.3641051-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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?= , Markus Armbruster , Richard Henderson , Mark Cave-Ayland , qemu-devel@nongnu.org, Eric Blake , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , "Dr. David Alan Gilbert" 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é Tested-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220105135009.1584676-23-alex.bennee@linaro.org> diff --git a/qapi/machine.json b/qapi/machine.json index b6a37e17c4..c87c81b803 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1503,6 +1503,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 14e3beeaaf..db4d186448 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -368,37 +368,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``