qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: pbonzini@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org,
	Wanlong Gao <gaowanlong@cn.fujitsu.com>,
	Andre Przywara <andre.przywara@amd.com>
Subject: Re: [Qemu-devel] [PATCH v18 03/14] NUMA: Add numa_info structure to contain numa nodes info
Date: Wed, 19 Feb 2014 10:26:51 +0100	[thread overview]
Message-ID: <20140219102651.113996d6@nial.usersys.redhat.com> (raw)
In-Reply-To: <3955e9989b37b41783a165e709b1bdcdfb82e9a8.1392794450.git.hutao@cn.fujitsu.com>

On Wed, 19 Feb 2014 15:53:54 +0800
Hu Tao <hutao@cn.fujitsu.com> wrote:

> From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> 
> Add the numa_info structure to contain the numa nodes memory,
> VCPUs information and the future added numa nodes host memory
> policies.
this is old version that breaks spar build which Wanlong already fixed.

You can replace patches 1-5 with more recent ones posted recently:
http://www.mail-archive.com/qemu-devel@nongnu.org/msg216404.html

> 
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/i386/pc.c            | 12 ++++++++----
>  include/sysemu/sysemu.h |  8 ++++++--
>  monitor.c               |  2 +-
>  numa.c                  | 23 ++++++++++++-----------
>  vl.c                    |  7 +++----
>  5 files changed, 30 insertions(+), 22 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index e715a33..a464e48 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -674,14 +674,14 @@ static FWCfgState *bochs_bios_init(void)
>          unsigned int apic_id = x86_cpu_apic_id_from_index(i);
>          assert(apic_id < apic_id_limit);
>          for (j = 0; j < nb_numa_nodes; j++) {
> -            if (test_bit(i, node_cpumask[j])) {
> +            if (test_bit(i, numa_info[j].node_cpu)) {
>                  numa_fw_cfg[apic_id + 1] = cpu_to_le64(j);
>                  break;
>              }
>          }
>      }
>      for (i = 0; i < nb_numa_nodes; i++) {
> -        numa_fw_cfg[apic_id_limit + 1 + i] = cpu_to_le64(node_mem[i]);
> +        numa_fw_cfg[apic_id_limit + 1 + i] = cpu_to_le64(numa_info[i].node_mem);
>      }
>      fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg,
>                       (1 + apic_id_limit + nb_numa_nodes) *
> @@ -1077,8 +1077,12 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
>      guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
>      guest_info->apic_xrupt_override = kvm_allows_irq0_override();
>      guest_info->numa_nodes = nb_numa_nodes;
> -    guest_info->node_mem = g_memdup(node_mem, guest_info->numa_nodes *
> +    guest_info->node_mem = g_malloc0(guest_info->numa_nodes *
>                                      sizeof *guest_info->node_mem);
> +    for (i = 0; i < nb_numa_nodes; i++) {
> +        guest_info->node_mem[i] = numa_info[i].node_mem;
> +    }
> +
>      guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit *
>                                       sizeof *guest_info->node_cpu);
>  
> @@ -1086,7 +1090,7 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
>          unsigned int apic_id = x86_cpu_apic_id_from_index(i);
>          assert(apic_id < guest_info->apic_id_limit);
>          for (j = 0; j < nb_numa_nodes; j++) {
> -            if (test_bit(i, node_cpumask[j])) {
> +            if (test_bit(i, numa_info[j].node_cpu)) {
>                  guest_info->node_cpu[apic_id] = j;
>                  break;
>              }
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 2509649..d873b42 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -9,6 +9,7 @@
>  #include "qapi-types.h"
>  #include "qemu/notify.h"
>  #include "qemu/main-loop.h"
> +#include "qemu/bitmap.h"
>  
>  /* vl.c */
>  
> @@ -134,8 +135,11 @@ extern QEMUClockType rtc_clock;
>  #define MAX_NODES 64
>  #define MAX_CPUMASK_BITS 255
>  extern int nb_numa_nodes;
> -extern uint64_t node_mem[MAX_NODES];
> -extern unsigned long *node_cpumask[MAX_NODES];
> +typedef struct node_info {
> +    uint64_t node_mem;
> +    DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS);
> +} NodeInfo;
> +extern NodeInfo numa_info[MAX_NODES];
>  void numa_add(const char *optarg);
>  void set_numa_nodes(void);
>  void set_numa_modes(void);
> diff --git a/monitor.c b/monitor.c
> index 690c152..0284735 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2004,7 +2004,7 @@ static void do_info_numa(Monitor *mon, const QDict *qdict)
>          }
>          monitor_printf(mon, "\n");
>          monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
> -            node_mem[i] >> 20);
> +            numa_info[i].node_mem >> 20);
>      }
>  }
>  
> diff --git a/numa.c b/numa.c
> index a06e2d1..1f413a0 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -61,7 +61,7 @@ static void numa_node_parse_cpus(int nodenr, const char *cpus)
>          goto error;
>      }
>  
> -    bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
> +    bitmap_set(numa_info[nodenr].node_cpu, value, endvalue-value+1);
>      return;
>  
>  error:
> @@ -101,7 +101,7 @@ void numa_add(const char *optarg)
>          }
>  
>          if (get_param_value(option, 128, "mem", optarg) == 0) {
> -            node_mem[nodenr] = 0;
> +            numa_info[nodenr].node_mem = 0;
>          } else {
>              int64_t sval;
>              sval = strtosz(option, &endptr);
> @@ -109,7 +109,7 @@ void numa_add(const char *optarg)
>                  fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
>                  exit(1);
>              }
> -            node_mem[nodenr] = sval;
> +            numa_info[nodenr].node_mem = sval;
>          }
>          if (get_param_value(option, 128, "cpus", optarg) != 0) {
>              numa_node_parse_cpus(nodenr, option);
> @@ -134,7 +134,7 @@ void set_numa_nodes(void)
>           * and distribute the available memory equally across all nodes
>           */
>          for (i = 0; i < nb_numa_nodes; i++) {
> -            if (node_mem[i] != 0) {
> +            if (numa_info[i].node_mem != 0) {
>                  break;
>              }
>          }
> @@ -145,15 +145,16 @@ void set_numa_nodes(void)
>               * the final node gets the rest.
>               */
>              for (i = 0; i < nb_numa_nodes - 1; i++) {
> -                node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
> -                usedmem += node_mem[i];
> +                numa_info[i].node_mem = (ram_size / nb_numa_nodes) &
> +                                        ~((1 << 23UL) - 1);
> +                usedmem += numa_info[i].node_mem;
>              }
> -            node_mem[i] = ram_size - usedmem;
> +            numa_info[i].node_mem = ram_size - usedmem;
>          }
>  
>          uint64_t numa_total = 0;
>          for (i = 0; i < nb_numa_nodes; i++) {
> -            numa_total += node_mem[i];
> +            numa_total += numa_info[i].node_mem;
>          }
>          if (numa_total != ram_size) {
>              fprintf(stderr, "qemu: numa nodes total memory size "
> @@ -162,7 +163,7 @@ void set_numa_nodes(void)
>          }
>  
>          for (i = 0; i < nb_numa_nodes; i++) {
> -            if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) {
> +            if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
>                  break;
>              }
>          }
> @@ -172,7 +173,7 @@ void set_numa_nodes(void)
>           */
>          if (i == nb_numa_nodes) {
>              for (i = 0; i < max_cpus; i++) {
> -                set_bit(i, node_cpumask[i % nb_numa_nodes]);
> +                set_bit(i, numa_info[i % nb_numa_nodes].node_cpu);
>              }
>          }
>      }
> @@ -185,7 +186,7 @@ void set_numa_modes(void)
>  
>      CPU_FOREACH(cpu) {
>          for (i = 0; i < nb_numa_nodes; i++) {
> -            if (test_bit(cpu->cpu_index, node_cpumask[i])) {
> +            if (test_bit(cpu->cpu_index, numa_info[i].node_cpu)) {
>                  cpu->numa_node = i;
>              }
>          }
> diff --git a/vl.c b/vl.c
> index 0adac0c..915f8b7 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -196,8 +196,7 @@ static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
>      QTAILQ_HEAD_INITIALIZER(fw_boot_order);
>  
>  int nb_numa_nodes;
> -uint64_t node_mem[MAX_NODES];
> -unsigned long *node_cpumask[MAX_NODES];
> +NodeInfo numa_info[MAX_NODES];
>  
>  uint8_t qemu_uuid[16];
>  bool qemu_uuid_set;
> @@ -2787,8 +2786,8 @@ int main(int argc, char **argv, char **envp)
>      translation = BIOS_ATA_TRANSLATION_AUTO;
>  
>      for (i = 0; i < MAX_NODES; i++) {
> -        node_mem[i] = 0;
> -        node_cpumask[i] = bitmap_new(MAX_CPUMASK_BITS);
> +        numa_info[i].node_mem = 0;
> +        bitmap_zero(numa_info[i].node_cpu, MAX_CPUMASK_BITS);
>      }
>  
>      nb_numa_nodes = 0;

  reply	other threads:[~2014-02-19  9:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19  7:53 [Qemu-devel] [PATCH v18 00/14] Add support for binding guest numa nodes to host numa nodes Hu Tao
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 01/14] NUMA: move numa related code to new file numa.c Hu Tao
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 02/14] NUMA: check if the total numa memory size is equal to ram_size Hu Tao
2014-02-25 13:38   ` Eric Blake
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 03/14] NUMA: Add numa_info structure to contain numa nodes info Hu Tao
2014-02-19  9:26   ` Igor Mammedov [this message]
2014-02-21  2:54     ` hu tao
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 04/14] NUMA: convert -numa option to use OptsVisitor Hu Tao
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 05/14] NUMA: expand MAX_NODES from 64 to 128 Hu Tao
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 06/14] qapi: add SIZE type parser to string_input_visitor Hu Tao
2014-02-19  9:54   ` Igor Mammedov
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 07/14] add memdev backend infrastructure Hu Tao
2014-02-19  9:15   ` Igor Mammedov
2014-02-19  7:53 ` [Qemu-devel] [PATCH v18 08/14] pc: pass QEMUMachineInitArgs to pc_memory_init Hu Tao
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 09/14] numa: introduce memory_region_allocate_system_memory Hu Tao
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 10/14] numa: add -numa node, memdev= option Hu Tao
2014-02-19  9:50   ` Igor Mammedov
2014-02-19 11:53     ` Paolo Bonzini
2014-03-04  0:10   ` Eric Blake
2014-03-04  2:20     ` Hu Tao
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 11/14] qapi: make string input visitor parse int list Hu Tao
2014-02-19  8:17   ` Hu Tao
2014-02-19  8:42     ` Paolo Bonzini
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 12/14] qapi: add HostMemPolicy enum type Hu Tao
2014-02-19  9:08   ` Paolo Bonzini
2014-02-19 11:23   ` Igor Mammedov
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 13/14] memory backend: fill memory backend ram fields Hu Tao
2014-02-19  9:03   ` Paolo Bonzini
2014-02-19  9:36     ` Igor Mammedov
2014-02-25 10:20       ` Hu Tao
2014-02-25 14:15         ` Paolo Bonzini
2014-02-26  5:00           ` Hu Tao
2014-02-26  8:47             ` Igor Mammedov
2014-02-26  8:59               ` Hu Tao
2014-02-26 12:19                 ` Igor Mammedov
2014-02-26 11:22               ` Paolo Bonzini
2014-02-26  5:57       ` Hu Tao
2014-02-26  9:05         ` Paolo Bonzini
2014-02-26  9:10         ` Igor Mammedov
2014-02-26 10:33           ` Paolo Bonzini
2014-02-26 12:31             ` Igor Mammedov
2014-02-26 12:45               ` Paolo Bonzini
2014-02-26 12:58                 ` Marcelo Tosatti
2014-02-26 13:14                   ` Paolo Bonzini
2014-02-26 13:43                 ` Igor Mammedov
2014-02-26 13:47                   ` Paolo Bonzini
2014-02-26 14:25                     ` Igor Mammedov
2014-02-26 14:39                       ` Paolo Bonzini
2014-02-25 10:09     ` Hu Tao
2014-03-03  3:24       ` Hu Tao
2014-02-19  7:54 ` [Qemu-devel] [PATCH v18 14/14] amp: add query-memdev Hu Tao
2014-02-19  8:14   ` Hu Tao
2014-02-19  9:07   ` Paolo Bonzini

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=20140219102651.113996d6@nial.usersys.redhat.com \
    --to=imammedo@redhat.com \
    --cc=andre.przywara@amd.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.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 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).