From nobody Thu May 16 05:16:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1658883625; cv=none; d=zohomail.com; s=zohoarc; b=BQWQx7deRszkk45pXM7iwdMZ+lpPG7O7GRF0q5of/mQeU0eHYpg8r264uxPb362FaCPFI1QTZVuZhJbiEYaxlhFeX1UrORMkNk4n0JnXCzjK4lLXh4N/cw5UfG8qMvuBPe9DvTfUKI/h1MDSIcHgZwhx/3QT7LI12OmiJWHhLvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658883625; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oJtzbWnfMv8rTJc5i0inF4KBXy+GPpRhVUvn7ujv64M=; b=XZzBnh1C8XhlmtX86o7sdbsLE4c2BRPe27YrJOXGnG5SDBRgaC47+A4S8rd0f9ffG+UB38Drj5F0WKbBrReOzUIa0D7SwNDYj8+D4dLN5IObFL9/C87HlmWQWNetrMllCAIO7N/cT4tP3XnTDR5FfaA4+kooutCY36lja03A+LE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658883625737937.9219820793618; Tue, 26 Jul 2022 18:00:25 -0700 (PDT) Received: from localhost ([::1]:52692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGVPT-0007at-Ht for importer@patchew.org; Tue, 26 Jul 2022 21:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGVLq-0004KO-PM for qemu-devel@nongnu.org; Tue, 26 Jul 2022 20:56:38 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:36735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGVLp-0004UZ-24 for qemu-devel@nongnu.org; Tue, 26 Jul 2022 20:56:38 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x1so13062022plb.3 for ; Tue, 26 Jul 2022 17:56:36 -0700 (PDT) Received: from always-x1.bytedance.net ([61.120.150.72]) by smtp.gmail.com with ESMTPSA id m1-20020a62a201000000b005289ef6db79sm12311859pff.32.2022.07.26.17.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 17:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oJtzbWnfMv8rTJc5i0inF4KBXy+GPpRhVUvn7ujv64M=; b=nPpwkHfbocwRxSQCowxlA/apMX2v1fDVWq/BEpM1j9tDvCoMKwxsAhbSrSw4bOD9VP uaQjSIp7oE33GTQ8ua82tFXGEXLJttaOGc77ydAgC0OHaIClmbLZvMI5eZkyR/RQOXDm xZkN3rqlp31anX0un8leLapEvSHmAMnggXsh8p5luqzWtFibT2v9B7gEE6IC44psrnYf /yvLxuE06T8CMJOENhmxbaw2mKsLWsx08RCWSFGQT8B5ViAzClLDLLSccGPPRSyiX9yZ DNSi6cc8ETaAywh+Sx0WTZBtmFYNqfEOKWKuhiK/jfZarvBZEON+3tIO6Nkxf8WV0Ym9 /MyA== 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=oJtzbWnfMv8rTJc5i0inF4KBXy+GPpRhVUvn7ujv64M=; b=pNwnzHnH9DmVxO4W/3TaxeDEnYERXIcmhCpeBngsotj4hqwZA0nUDqCHhWnWxK3oDh 9v7b6cGN/rRM3P/oB2TnNCWjC3MfM2wOCJ24vyiOHF4PHwwJaqhXoJUJDw64pbnkEtdm 7b3gEZKv+L9lZ20nm65SwQ7/CdPSxzZJcQR15rf1a+dL7z/0sBuRV6yfd3ahL2pHQZqZ 6jUeRnxd8GJiesPMJnnep54FrtvNBQh3Qc4o5lmoWldj3b5shsplEuZT6L0t7YsxxKBQ WZU0FpFwqCOMwsgdSMyZCbIBdKarFUYvHypWC3E5wvbuL0ZoHMeyDXUxf/VJ5fcuOcug badg== X-Gm-Message-State: AJIora/ce14DZfefC/zWTZb7404DOkTp3N6xGKAoIH0vr9PDtqoVSe3k VsbBuSdq9CG3hd5901Q2aryXOw== X-Google-Smtp-Source: AGRyM1uJjHDSzeXWxu0dSh/3HGacwziU5GY5ug2SygfCQHNkc3T0zGj+EBNxuyfZcI+cwJQklINBuQ== X-Received: by 2002:a17:902:f70c:b0:16d:20ef:7e42 with SMTP id h12-20020a170902f70c00b0016d20ef7e42mr19148227plo.54.1658883395792; Tue, 26 Jul 2022 17:56:35 -0700 (PDT) From: zhenwei pi To: dgilbert@redhat.com Cc: qemu-devel@nongnu.org, armbru@redhat.com, zhenwei pi , Darren Kenny Subject: [PATCH v2 1/1] monitor: Support specified vCPU registers Date: Wed, 27 Jul 2022 08:51:23 +0800 Message-Id: <20220727005123.1093478-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727005123.1093478-1-pizhenwei@bytedance.com> References: <20220727005123.1093478-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=pizhenwei@bytedance.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bytedance-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1658883626913100001 Content-Type: text/plain; charset="utf-8" Originally we have to get all the vCPU registers and parse the specified one. To improve the performance of this usage, allow user specified vCPU id to query registers. Run a VM with 16 vCPU, use bcc tool to track the latency of 'hmp_info_registers': 'info registers -a' uses about 3ms; 'info registers 12' uses about 150us. Cc: Darren Kenny Signed-off-by: zhenwei pi --- hmp-commands-info.hx | 7 ++++--- monitor/misc.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 3ffa24bd67..7a00b4ded3 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -100,9 +100,10 @@ ERST =20 { .name =3D "registers", - .args_type =3D "cpustate_all:-a", - .params =3D "[-a]", - .help =3D "show the cpu registers (-a: all - show register i= nfo for all cpus)", + .args_type =3D "cpustate_all:-a,vcpu:i?", + .params =3D "[-a|vcpu]", + .help =3D "show the cpu registers (-a: all - show register i= nfo for all cpus;" + " vcpu: specific vCPU to query)", .cmd =3D hmp_info_registers, }, =20 diff --git a/monitor/misc.c b/monitor/misc.c index 3d2312ba8d..8e1d4840f2 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon) static void hmp_info_registers(Monitor *mon, const QDict *qdict) { bool all_cpus =3D qdict_get_try_bool(qdict, "cpustate_all", false); + int vcpu =3D qdict_get_try_int(qdict, "vcpu", -1); CPUState *cs; =20 if (all_cpus) { @@ -314,6 +315,23 @@ static void hmp_info_registers(Monitor *mon, const QDi= ct *qdict) monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); cpu_dump_state(cs, NULL, CPU_DUMP_FPU); } + } else if (vcpu >=3D 0) { + CPUState *target_cs =3D NULL; + + CPU_FOREACH(cs) { + if (cs->cpu_index =3D=3D vcpu) { + target_cs =3D cs; + break; + } + } + + if (!target_cs) { + monitor_printf(mon, "CPU#%d not available\n", vcpu); + return; + } + + monitor_printf(mon, "\nCPU#%d\n", target_cs->cpu_index); + cpu_dump_state(target_cs, NULL, CPU_DUMP_FPU); } else { cs =3D mon_get_cpu(mon); =20 --=20 2.20.1