diff mbox series

[v2,01/10] hw/boards: add struct CpuTopology to MachineState

Message ID 1557131596-25403-2-git-send-email-like.xu@linux.intel.com
State New
Headers show
Series refactor cpu topo into machine properties | expand

Commit Message

Like Xu May 6, 2019, 8:33 a.m. UTC
To remove usages of global smp variables arch by arch,
a bisect friendly way is introduced to initialize struct
CpuTopology with duplicate ones; no semantic changes.

Suggested-by: Igor Mammedov <imammedo@redhat.com>
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
---
 include/hw/boards.h | 15 +++++++++++++++
 vl.c                |  5 +++++
 2 files changed, 20 insertions(+)

Comments

Alistair Francis May 9, 2019, 4:32 p.m. UTC | #1
On Mon, May 6, 2019 at 1:34 AM Like Xu <like.xu@linux.intel.com> wrote:
>
> To remove usages of global smp variables arch by arch,
> a bisect friendly way is introduced to initialize struct
> CpuTopology with duplicate ones; no semantic changes.
>
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair


> ---
>  include/hw/boards.h | 15 +++++++++++++++
>  vl.c                |  5 +++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 6f7916f..dc89c6d 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -231,6 +231,20 @@ typedef struct DeviceMemoryState {
>  } DeviceMemoryState;
>
>  /**
> + * CpuTopology:
> + * @cpus: the number of logical processors on the machine
> + * @cores: the number of cores in one package
> + * @threads: the number of threads in one core
> + * @max_cpus: the maximum number of logical processors on the machine
> + */
> +typedef struct CpuTopology {
> +    unsigned int cpus;
> +    unsigned int cores;
> +    unsigned int threads;
> +    unsigned int max_cpus;
> +} CpuTopology;
> +
> +/**
>   * MachineState:
>   */
>  struct MachineState {
> @@ -272,6 +286,7 @@ struct MachineState {
>      const char *cpu_type;
>      AccelState *accelerator;
>      CPUArchIdList *possible_cpus;
> +    CpuTopology smp;
>      struct NVDIMMState *nvdimms_state;
>  };
>
> diff --git a/vl.c b/vl.c
> index d9fea0a..43fd247 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4099,6 +4099,11 @@ int main(int argc, char **argv, char **envp)
>
>      smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
>
> +    current_machine->smp.cpus = smp_cpus;
> +    current_machine->smp.max_cpus = max_cpus;
> +    current_machine->smp.cores = smp_cores;
> +    current_machine->smp.threads = smp_threads;
> +
>      /* sanity-check smp_cpus and max_cpus against machine_class */
>      if (smp_cpus < machine_class->min_cpus) {
>          error_report("Invalid SMP CPUs %d. The min CPUs "
> --
> 1.8.3.1
>
Igor Mammedov May 17, 2019, 8:46 a.m. UTC | #2
On Mon,  6 May 2019 16:33:07 +0800
Like Xu <like.xu@linux.intel.com> wrote:

> To remove usages of global smp variables arch by arch,
> a bisect friendly way is introduced to initialize struct
> CpuTopology with duplicate ones; no semantic changes.

well, commit message doesn't make any sense however many
times I've tried to read it. Pls rephrase.
 
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>
> ---
>  include/hw/boards.h | 15 +++++++++++++++
>  vl.c                |  5 +++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 6f7916f..dc89c6d 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -231,6 +231,20 @@ typedef struct DeviceMemoryState {
>  } DeviceMemoryState;
>  
>  /**
> + * CpuTopology:
> + * @cpus: the number of logical processors on the machine

s/of/of present/

> + * @cores: the number of cores in one package
> + * @threads: the number of threads in one core
> + * @max_cpus: the maximum number of logical processors on the machine
> + */
> +typedef struct CpuTopology {
> +    unsigned int cpus;
> +    unsigned int cores;
> +    unsigned int threads;
> +    unsigned int max_cpus;
> +} CpuTopology;
> +
> +/**
>   * MachineState:
>   */
>  struct MachineState {
> @@ -272,6 +286,7 @@ struct MachineState {
>      const char *cpu_type;
>      AccelState *accelerator;
>      CPUArchIdList *possible_cpus;
> +    CpuTopology smp;
>      struct NVDIMMState *nvdimms_state;
>  };
>  
> diff --git a/vl.c b/vl.c
> index d9fea0a..43fd247 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4099,6 +4099,11 @@ int main(int argc, char **argv, char **envp)
>  
>      smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
>  
> +    current_machine->smp.cpus = smp_cpus;
> +    current_machine->smp.max_cpus = max_cpus;
> +    current_machine->smp.cores = smp_cores;
> +    current_machine->smp.threads = smp_threads;
> +
>      /* sanity-check smp_cpus and max_cpus against machine_class */
>      if (smp_cpus < machine_class->min_cpus) {
>          error_report("Invalid SMP CPUs %d. The min CPUs "
diff mbox series

Patch

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 6f7916f..dc89c6d 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -231,6 +231,20 @@  typedef struct DeviceMemoryState {
 } DeviceMemoryState;
 
 /**
+ * CpuTopology:
+ * @cpus: the number of logical processors on the machine
+ * @cores: the number of cores in one package
+ * @threads: the number of threads in one core
+ * @max_cpus: the maximum number of logical processors on the machine
+ */
+typedef struct CpuTopology {
+    unsigned int cpus;
+    unsigned int cores;
+    unsigned int threads;
+    unsigned int max_cpus;
+} CpuTopology;
+
+/**
  * MachineState:
  */
 struct MachineState {
@@ -272,6 +286,7 @@  struct MachineState {
     const char *cpu_type;
     AccelState *accelerator;
     CPUArchIdList *possible_cpus;
+    CpuTopology smp;
     struct NVDIMMState *nvdimms_state;
 };
 
diff --git a/vl.c b/vl.c
index d9fea0a..43fd247 100644
--- a/vl.c
+++ b/vl.c
@@ -4099,6 +4099,11 @@  int main(int argc, char **argv, char **envp)
 
     smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
 
+    current_machine->smp.cpus = smp_cpus;
+    current_machine->smp.max_cpus = max_cpus;
+    current_machine->smp.cores = smp_cores;
+    current_machine->smp.threads = smp_threads;
+
     /* sanity-check smp_cpus and max_cpus against machine_class */
     if (smp_cpus < machine_class->min_cpus) {
         error_report("Invalid SMP CPUs %d. The min CPUs "