From patchwork Tue Dec 14 19:50:48 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: 523670 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp7992250imb; Tue, 14 Dec 2021 11:59:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJygs8mEhZqnW0W5AAwvBpKbnYvx5zqkTjJBxRQZGzENfQ5801jhBf5IHuPtPS11okpDvRDj X-Received: by 2002:a05:6122:1531:: with SMTP id g17mr1571566vkq.32.1639511948660; Tue, 14 Dec 2021 11:59:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639511948; cv=none; d=google.com; s=arc-20160816; b=IP+81m2IaNVSCMj2zKznj9To4E25wI1NAIUc4e2H8O4f+vqB73FNaBk95tJnPSrDeW w15jyQeIX3StAeZgdIFvaEuDFn8nIyqgs498WRq6MGdgwPhaCxmovYFpDyLmxZpVpDaQ /7MBaujcNRY6YJcAg8RFt/5o/5hXvSKwevkSLMBenJBdUTqFeRFC8txc0Ui5XYF0RaXg uqegPWStWgwW7/aec6o1tQOvaj+fi0ODQBfb+i8PXxH3zVVk7cYWLP22U/UdYjLrkw5W 64qCVU+auF6TWe8XRFRaec+EHPc7Kw1/Txh41xXKoHmLtQThpjdWRGAhXvU3XuNu2TLZ St/Q== 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=fPLE86TguE5CkK57HQyIAIvuRVzxXAz3nreJFzgQc5k=; b=uvzp2efxoYNRF9qq+rj/kmw+fXjzsMmyhLkoSyvFCu5cClhODg3jRBPf8WHNCmXXe+ XKH1s3MQ4n8qKTtu9oad0v3AGH+VHxceea0fIJ71IJcN3DfZLAa6NuyPW/2JlwOhheQ6 KzfT7QHjYZLhzWnInrScfjCeZcyHfpQqPGTGO0CVasgb+PsXNu7OfmBD9YJ8AE+OQCFB ZvbXCPQftGX0wUr25BRNd1/RYUx7aoWt2QXWTFsN+4ckyap3C1QvqGqVqeD4aJtZuayP Vkr0GmLMcnkY8RMWfQIqarvP2eCBitoUg/ep0obLzWUwwnb2aR57PP/hRAuTTOgjW6RE 9hXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d40X+wdK; 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 g23si986526vkg.61.2021.12.14.11.59.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Dec 2021 11:59:08 -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=d40X+wdK; 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]:52858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxDx6-0005b6-2H for patch@linaro.org; Tue, 14 Dec 2021 14:59:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxDwb-0005aX-6x for qemu-devel@nongnu.org; Tue, 14 Dec 2021 14:58:37 -0500 Received: from [2607:f8b0:4864:20::1034] (port=42712 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxDwZ-00015c-BZ for qemu-devel@nongnu.org; Tue, 14 Dec 2021 14:58:36 -0500 Received: by mail-pj1-x1034.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so17005224pjb.1 for ; Tue, 14 Dec 2021 11:58:34 -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=fPLE86TguE5CkK57HQyIAIvuRVzxXAz3nreJFzgQc5k=; b=d40X+wdK0KvIHXpZRUxItEvYJrAH8UtqQMV7OYBz3Ddhr7PfV+rE7XangCkHS9A3E3 BU2ke5Z/qwR6+4Gg6NgnuzDur58T81RlL2z17z5mSEEYENUm4EwFCeCOM2+wxZXozVB2 O06K8J7nG+Dju7xfOwUhmlZGb8Cxfr5xOfpmP0jzHAbBFJgCjYviEW0PfOdtbJ2HGQ2/ KhnWDbbQp/hD/kPfjTn4mq4ef47iQ4p/SW1rZzVL8H6y4tIn82c3cPghPGIyJ24mToeh PDFusf13RK4Wy52xGcuqim8i3NbOC9yZmz3Q2nTMHBQf0AfxGZh6JuSiewcIjxpM/QFt 46NA== 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=fPLE86TguE5CkK57HQyIAIvuRVzxXAz3nreJFzgQc5k=; b=ZWqIUQlh29jpnWOxWmXaHrb7donbC/P0KYaeGXD3gbtppPRDtDolcKwMGZqwNmxJZJ gQOLc8aoBMyyeukZlicZVIlm4psEuvRXkjVZDSLhV5Afh8OtHkRX+yz1GGqY7MimSA6+ yO0FNXVzZgU717rOTNToSzV1iS1UjdJ1RRYTDLQkt7dfxRO5ErF866Cyt2ExGu44hu3c 7syHc/vPNXMd8nvGxIfqWT9upvv1OaWPDi/auJjdGj95R+znbnAhOP1RmXjQBgK6TXAJ RdNOTy+rhqRmSk2uDuumcNm+pc6zPYPLASqTC7VePCa6A84jchn5b5bce4icdSL3+SYU uPtw== X-Gm-Message-State: AOAM532fsTXnduBwXngZ1ujZHIjhtkSjA33QOk6rxDyc19DcWgug/fzG 0+cQlmN+675dSXkSnXsRnK37IHl/1u9a0g== X-Received: by 2002:a1f:2849:: with SMTP id o70mr1399341vko.35.1639511456872; Tue, 14 Dec 2021 11:50:56 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g187sm170966vsc.10.2021.12.14.11.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 11:50:55 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DFFE61FF96; Tue, 14 Dec 2021 19:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2] monitor: move x-query-profile into accel/tcg to fix build Date: Tue, 14 Dec 2021 19:50:48 +0000 Message-Id: <20211214195048.1438209-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 2607:f8b0:4864:20::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=alex.bennee@linaro.org; helo=mail-pj1-x1034.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 , Mark Cave-Ayland , Markus Armbruster , Eric Blake , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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é --- v2 - enclosed in #ifndef CONFIG_USER_ONLY section --- qapi/machine.json | 1 + accel/tcg/cpu-exec.c | 31 +++++++++++++++++++++++++++++++ monitor/qmp-cmds.c | 31 ------------------------------- 3 files changed, 32 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;