qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Yi Wang <wang.yi59@zte.com.cn>
Cc: dgilbert@redhat.com, armbru@redhat.com, pbonzini@redhat.com,
	rth@twiddle.net, ehabkost@redhat.com, qemu-devel@nongnu.org,
	liu.yunh@zte.com.cn, Liu.Jianjun3@zte.com.cn
Subject: Re: [Qemu-devel] [PATCH 1/2] [PATCH] hmp: dump ids including socket-id, core-id and so on for 'info registers'
Date: Fri, 21 Jul 2017 15:24:05 +0200	[thread overview]
Message-ID: <20170721152405.73701263@nial.brq.redhat.com> (raw)
In-Reply-To: <1500622736-20865-2-git-send-email-wang.yi59@zte.com.cn>

On Fri, 21 Jul 2017 03:38:55 -0400
Yi Wang <wang.yi59@zte.com.cn> wrote:

> This patch add output of CPUs' socket-id, core-id, thread-id and
> apic-id for 'info registers', which can be used for querying other
> hmp commands.
> 
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
> Signed-off-by: Yun Liu <liu.yunh@zte.com.cn>
> ---
>  include/qom/cpu.h    | 12 ++++++++++++
>  monitor.c            |  1 +
>  qom/cpu.c            | 10 ++++++++++
>  target/i386/cpu.c    |  1 +
>  target/i386/cpu.h    |  1 +
>  target/i386/helper.c | 13 +++++++++++++
>  6 files changed, 38 insertions(+)
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 25eefea..4717bd7 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -92,6 +92,7 @@ struct TranslationBlock;
>   * CPUs can use the default implementation of this method. This method should
>   * not be used by any callers other than the pre-1.0 virtio devices.
>   * @memory_rw_debug: Callback for GDB memory access.
> + * @dump_ids: Callback for dumping ids.
>   * @dump_state: Callback for dumping state.
>   * @dump_statistics: Callback for dumping statistics.
>   * @get_arch_id: Callback for getting architecture-dependent CPU ID.
> @@ -156,6 +157,7 @@ typedef struct CPUClass {
>      bool (*virtio_is_big_endian)(CPUState *cpu);
>      int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>                             uint8_t *buf, int len, bool is_write);
> +    void (*dump_ids)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf);
>      void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>                         int flags);
>      GuestPanicInformation* (*get_crash_info)(CPUState *cpu);
> @@ -518,6 +520,16 @@ enum CPUDumpFlags {
>  };
>  
>  /**
> + * cpu_dump_ids:
> + * @cpu: The CPU whose state is to be dumped.
> + * @f: File to dump to.
> + * @cpu_fprintf: Function to dump with.
> + *
> + * Dumps CPU socket-id, core-id, thread-id and apic-id.
> + */
> +void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf);
> +
> +/**
>   * cpu_dump_state:
>   * @cpu: The CPU whose state is to be dumped.
>   * @f: File to dump to.
> diff --git a/monitor.c b/monitor.c
> index 6d040e6..30f898c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1085,6 +1085,7 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>      if (all_cpus) {
>          CPU_FOREACH(cs) {
>              monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
> +            cpu_dump_ids(cs, (FILE *)mon, monitor_fprintf);
>              cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
>          }
>      } else {
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 4f38db0..a9df661 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -242,6 +242,16 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
>      return res;
>  }
>  
> +void cpu_dump_ids(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf)
> +{
> +    CPUClass *cc = CPU_GET_CLASS(cpu);
> +
> +    if (cc->dump_ids) {
> +        cpu_synchronize_state(cpu);
> +        cc->dump_ids(cpu, f, cpu_fprintf);
> +    }
> +}
> +
>  void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
>                      int flags)
>  {
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 0bbda76..0aa488f 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -4120,6 +4120,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>      cc->do_interrupt = x86_cpu_do_interrupt;
>      cc->cpu_exec_interrupt = x86_cpu_exec_interrupt;
>  #endif
> +    cc->dump_ids = x86_cpu_dump_ids;
>      cc->dump_state = x86_cpu_dump_state;
>      cc->get_crash_info = x86_cpu_get_crash_info;
>      cc->set_pc = x86_cpu_set_pc;
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 0518673..31ad681 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1316,6 +1316,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
>  void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
>                                  Error **errp);
>  
> +void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf);
>  void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>                          int flags);
>  
> diff --git a/target/i386/helper.c b/target/i386/helper.c
> index f63eb3d..fd4f1af 100644
> --- a/target/i386/helper.c
> +++ b/target/i386/helper.c
> @@ -408,6 +408,19 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f,
>  #define DUMP_CODE_BYTES_TOTAL    50
>  #define DUMP_CODE_BYTES_BACKWARD 20
>  
> +void x86_cpu_dump_ids(CPUState *cs, FILE *f, fprintf_function cpu_fprintf)
> +{


> +    X86CPU *cpu = X86_CPU(cs);
> +    APICCommonState *s = APIC_COMMON(cpu->apic_state);
> +    if (!s) {
> +        cpu_fprintf(f, "local apic state not available\n");
> +        return;
> +    }
> +
> +    cpu_fprintf(f, "(socket-id:%d core-id:%d thread-id:%d apic-id:%d)\n",
> +            cpu->socket_id, cpu->core_id, cpu->thread_id, s->id);

I'd move this hunk into x86_cpu_dump_state() and drop the rest of the patch.

If we'd need to generalize it for other targets, we could do it later.


> +}
> +
>  void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
>                          int flags)
>  {

  reply	other threads:[~2017-07-21 13:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21  7:38 [Qemu-devel] [PATCH 0/2] hmp: support querying lapic through Yi Wang
2017-07-21  7:38 ` [Qemu-devel] [PATCH 1/2] [PATCH] hmp: dump ids including socket-id, core-id and so on for 'info registers' Yi Wang
2017-07-21 13:24   ` Igor Mammedov [this message]
2017-07-21  7:38 ` [Qemu-devel] [PATCH 2/2] [PATCH] hmp: allow apic-id for "info lapic" Yi Wang
2017-07-21 19:40   ` Eduardo Habkost
2017-07-21  7:39 ` [Qemu-devel] [PATCH 0/2] hmp: support querying lapic through no-reply
2017-07-27 12:49 ` no-reply

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=20170721152405.73701263@nial.brq.redhat.com \
    --to=imammedo@redhat.com \
    --cc=Liu.Jianjun3@zte.com.cn \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=liu.yunh@zte.com.cn \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=wang.yi59@zte.com.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).