From patchwork Tue Dec 14 18:22:07 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: 523669 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp7885781imb; Tue, 14 Dec 2021 10:23:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzj5n7yZ83r8fAjRZit4HFP910Xh1cjnT0rRt5L8Jo58Wb1fGOas9d3saWCumuwyWE+pMK3 X-Received: by 2002:a37:bd82:: with SMTP id n124mr5576862qkf.728.1639506195747; Tue, 14 Dec 2021 10:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639506195; cv=none; d=google.com; s=arc-20160816; b=ODvHs01cLWz4j/gHWlO/9io5x49TIpefVKpYozSjqFvvBfCyJ72AVS31Ih57wnyA05 xmfYOVvL2ScId3MFmNDqk1nlV8mwJQBSRtj4+3KCx2LgnUqtK9+SeKf/4RtZUQncDCCp v5kGSK3wbtedQHX8U3uiLKFEmPttv9oQ65+s5pl/peLHCmI/OByu6Mpxem8ZjTAnloP+ k9zmGEYPwKyYPqpnjvFmrppspysuTKGyJd0wFzPAfgsVM04dzoDTA07Jk8XVyUd7DrK+ LpxyYuI4aLz6CLVarBnuIPiqjwSK7f2hk+chrx+mawOYb+1IhPF2iSIDrA2CmRACjGFw 23rA== 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=aLt2TUgSzLO10dQEKYLOpEEl8MmCeHXBkcOlhjmIuXA=; b=gQvbP8XJ9K8rsDf9vnyJXwjcHHwyySujhVVWNgKwoiRV1iXstTJwvgfdjgh8H/7FYu wpkXqAOY6llD/cqJYcPzskNH6RNXwHpSVlAilcRiuwTNaH1cRHgMvcMmKz/udxu/PQ5i S2fgJ8M7SRkw8KVLswiYT3KF0/d/l+HoAeT7GZM1yp3DpooeXIs7+kKbCjUIUh3BsPeG xSjWs/cuuU/qsC2LnNA/+xJaKLLcp1QA83tFiyN1lF2GmMRTfRlm5e8maiUeOBgur/2w T+sqfha9YgPtagKfXd40HF4kZEz5KrbP+rvmtumdGGYR6p9I4V49UcHmhdTWg1dkw77a XvAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="AWCrB/xP"; 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 j19si853872vka.257.2021.12.14.10.23.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Dec 2021 10:23:15 -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="AWCrB/xP"; 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]:51512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxCSJ-0002ny-53 for patch@linaro.org; Tue, 14 Dec 2021 13:23:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxCRU-0002no-PE for qemu-devel@nongnu.org; Tue, 14 Dec 2021 13:22:25 -0500 Received: from [2a00:1450:4864:20::42d] (port=47078 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxCRR-0004nc-H6 for qemu-devel@nongnu.org; Tue, 14 Dec 2021 13:22:23 -0500 Received: by mail-wr1-x42d.google.com with SMTP id i22so4107550wrb.13 for ; Tue, 14 Dec 2021 10:22:16 -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=aLt2TUgSzLO10dQEKYLOpEEl8MmCeHXBkcOlhjmIuXA=; b=AWCrB/xP3Kz/8ONQAcadMr4/oj/cukeUipKA2S+6znnZ3rXqd0TAWM6ot0fUsw1VXD 4WfThEFt94k6prvEVAKY0cW4++zehnLJSw/CedZViXBHq0q9kw5X59snYzUc1i3PZyHX U8+Iw03ThENLMQn//mASPSKjSH7zcJs/0d3C1nThC6+S9yjR7OOYhtu8FQXoNqJB5VNX Y86gHAVVkV77XKCFzJzKaLblOkHtdRPYyjk5izn7PJMMYTVmZPw9VslnIaLy10oxCUBo 9156QY+ASQeMi+7vDHXJy4R1IRnW5kUX1TTx0Ya8uE4B7ZzY5j/n6GuJzQpvYWJIH2Lj R0MA== 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=aLt2TUgSzLO10dQEKYLOpEEl8MmCeHXBkcOlhjmIuXA=; b=24KEXukmXLGhmEhuW+qlF7KLVQ8xcZ0NoS13xGwKVqZ3i9UYnYg+KV6dghTvMiyUJz OOoIxXgCE7fqXasN89gVInK0YtJi7OvxqGuv1jbYfd4UkADn8eLmtJZVAobWw2Jqp7IR +s9JfTu4E0GJg3+L6Y2wVAdZeiyABZqRodBs6w8aphojLGLYr17Q0ucg6p5BkSoLIZzz KoijNPuDsWUNBcy5+8SpasRm4Zy3W/ydW5IARPwmvStiWMfDVSNe4DnNtM3dXK7RrfNa kYHU3pUH9mFkB70fYL+fmyrGhvwUsnKx+O7qfro+rhbZ3g5V6ltC+MlQXoYTeyXHD2Ez gwZg== X-Gm-Message-State: AOAM530Q1d4+XI6QfUAsit4SqS9gN/X1hC8deGWwfYSTP/CaXYMRo0n/ jjp2QOnWrqQdHiP5xBL4jhEH9A== X-Received: by 2002:a05:6000:184e:: with SMTP id c14mr659863wri.241.1639506135181; Tue, 14 Dec 2021 10:22:15 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q24sm2706938wmj.21.2021.12.14.10.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 10:22:14 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 92C261FF96; Tue, 14 Dec 2021 18:22:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH] monitor: move x-query-profile into accel/tcg to fix build Date: Tue, 14 Dec 2021 18:22:07 +0000 Message-Id: <20211214182207.1416246-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::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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 --- 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..9498a16681 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -1091,3 +1091,34 @@ HumanReadableText *qmp_x_query_opcount(Error **errp) } #endif /* !CONFIG_USER_ONLY */ + +#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 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;