From: Darren Kenny <darren.kenny@oracle.com>
To: zhenwei pi <pizhenwei@bytedance.com>, dgilbert@redhat.com
Cc: qemu-devel@nongnu.org, armbru@redhat.com,
zhenwei pi <pizhenwei@bytedance.com>
Subject: Re: [PATCH] monitor: Support specified vCPU registers
Date: Tue, 26 Jul 2022 12:13:17 +0100 [thread overview]
Message-ID: <m2a68wxh2q.fsf@oracle.com> (raw)
In-Reply-To: <20220719075544.932927-1-pizhenwei@bytedance.com>
On Tuesday, 2022-07-19 at 15:55:44 +08, zhenwei pi wrote:
> 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 register 12' uses about 150us.
TYPO: I'm assuming that should be 'info registers 12'?
>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> ---
> hmp-commands-info.hx | 6 +++---
> monitor/misc.c | 19 +++++++++++++++++++
> 2 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 3ffa24bd67..6023e2b5c5 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -100,9 +100,9 @@ ERST
>
> {
> .name = "registers",
> - .args_type = "cpustate_all:-a",
> - .params = "[-a]",
> - .help = "show the cpu registers (-a: all - show register info for all cpus)",
> + .args_type = "cpustate_all:-a,vcpu:i?",
> + .params = "[-a] [vcpu]",
From what I can see in the code, only one of these may be specified at a
time - or at least, '-a' will take precedence.
Maybe it would read more correctly as '[-a|vcpu]' ?
> + .help = "show the cpu registers (-a: all - show register info for all cpus; vcpu: vCPU to query)",
Possibly also it would be worth saying "...; vcpu: specific vCPU to query"?
> .cmd = hmp_info_registers,
> },
>
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 3d2312ba8d..b12309faad 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 = qdict_get_try_bool(qdict, "cpustate_all", false);
> + int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
> CPUState *cs;
>
> if (all_cpus) {
> @@ -314,6 +315,24 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
> monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
> cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
> }
> + } else if (vcpu >= 0) {
> + CPUState *target_cs = NULL;
> +
> + CPU_FOREACH(cs) {
> + if (cs->cpu_index == vcpu) {
> + target_cs = 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);
> + return;
This return call seems unnecessary here.
Thanks,
Darren.
prev parent reply other threads:[~2022-07-26 11:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 7:55 [PATCH] monitor: Support specified vCPU registers zhenwei pi
2022-07-26 0:22 ` PING: " zhenwei pi
2022-07-26 11:13 ` Darren Kenny [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2a68wxh2q.fsf@oracle.com \
--to=darren.kenny@oracle.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=pizhenwei@bytedance.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.