[Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping

Igor Mammedov posted 24 patches 8 years, 9 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Igor Mammedov 8 years, 9 months ago
Default node mapping initialization already checks that board
supports cpu_index to node mapping and refuses to start if
it's not supported. Do the same for explicitly provided
mapping "-numa node,cpus=..."

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 numa.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/numa.c b/numa.c
index ab1661d..b517870 100644
--- a/numa.c
+++ b/numa.c
@@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
     return -1;
 }
 
-static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
+static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
+                            QemuOpts *opts, Error **errp)
 {
     uint16_t nodenr;
     uint16List *cpus = NULL;
+    MachineClass *mc = MACHINE_GET_CLASS(ms);
 
     if (node->has_nodeid) {
         nodenr = node->nodeid;
@@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
         return;
     }
 
+    if (!mc->cpu_index_to_instance_props) {
+        error_report("CPUs to NUMA node mapping isn't supported");
+        exit(1);
+    }
     for (cpus = node->cpus; cpus; cpus = cpus->next) {
         if (cpus->value >= max_cpus) {
             error_setg(errp,
@@ -215,6 +221,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
 static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
 {
     NumaOptions *object = NULL;
+    MachineState *ms = opaque;
     Error *err = NULL;
 
     {
@@ -229,7 +236,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
 
     switch (object->type) {
     case NUMA_OPTIONS_TYPE_NODE:
-        numa_node_parse(&object->u.node, opts, &err);
+        numa_node_parse(ms, &object->u.node, opts, &err);
         if (err) {
             goto end;
         }
@@ -303,7 +310,7 @@ void parse_numa_opts(MachineState *ms)
         numa_info[i].node_cpu = bitmap_new(max_cpus);
     }
 
-    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
+    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
         exit(1);
     }
 
-- 
2.7.4


Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Eduardo Habkost 8 years, 9 months ago
On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:
> Default node mapping initialization already checks that board
> supports cpu_index to node mapping and refuses to start if
> it's not supported. Do the same for explicitly provided
> mapping "-numa node,cpus=..."
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  numa.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/numa.c b/numa.c
> index ab1661d..b517870 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
>      return -1;
>  }
>  
> -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> +                            QemuOpts *opts, Error **errp)
>  {
>      uint16_t nodenr;
>      uint16List *cpus = NULL;
> +    MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
>      if (node->has_nodeid) {
>          nodenr = node->nodeid;
> @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>          return;
>      }
>  
> +    if (!mc->cpu_index_to_instance_props) {
> +        error_report("CPUs to NUMA node mapping isn't supported");
> +        exit(1);
> +    }

The error message sounds very confusing me. Maybe this could
become just: "NUMA is not supported by the %s machine-type"?

-- 
Eduardo

Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Igor Mammedov 8 years, 9 months ago
On Wed, 3 May 2017 12:04:29 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:
> > Default node mapping initialization already checks that board
> > supports cpu_index to node mapping and refuses to start if
> > it's not supported. Do the same for explicitly provided
> > mapping "-numa node,cpus=..."
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  numa.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/numa.c b/numa.c
> > index ab1661d..b517870 100644
> > --- a/numa.c
> > +++ b/numa.c
> > @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
> >      return -1;
> >  }
> >  
> > -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> > +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> > +                            QemuOpts *opts, Error **errp)
> >  {
> >      uint16_t nodenr;
> >      uint16List *cpus = NULL;
> > +    MachineClass *mc = MACHINE_GET_CLASS(ms);
> >  
> >      if (node->has_nodeid) {
> >          nodenr = node->nodeid;
> > @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> >          return;
> >      }
> >  
> > +    if (!mc->cpu_index_to_instance_props) {
> > +        error_report("CPUs to NUMA node mapping isn't supported");
> > +        exit(1);
> > +    }  
> 
> The error message sounds very confusing me. Maybe this could
> become just: "NUMA is not supported by the %s machine-type"?
If I replace this specific error message with a generic one and do
the same in 5/24, it will be harder for us/user to figure out
where exactly error happened.

Would be following clearer:
"option -numa node,cpus= is not supported by the %s machine-type"


Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Eduardo Habkost 8 years, 9 months ago
On Wed, May 03, 2017 at 06:19:50PM +0200, Igor Mammedov wrote:
> On Wed, 3 May 2017 12:04:29 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:
> > > Default node mapping initialization already checks that board
> > > supports cpu_index to node mapping and refuses to start if
> > > it's not supported. Do the same for explicitly provided
> > > mapping "-numa node,cpus=..."
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > ---
> > >  numa.c | 13 ++++++++++---
> > >  1 file changed, 10 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/numa.c b/numa.c
> > > index ab1661d..b517870 100644
> > > --- a/numa.c
> > > +++ b/numa.c
> > > @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
> > >      return -1;
> > >  }
> > >  
> > > -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> > > +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> > > +                            QemuOpts *opts, Error **errp)
> > >  {
> > >      uint16_t nodenr;
> > >      uint16List *cpus = NULL;
> > > +    MachineClass *mc = MACHINE_GET_CLASS(ms);
> > >  
> > >      if (node->has_nodeid) {
> > >          nodenr = node->nodeid;
> > > @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> > >          return;
> > >      }
> > >  
> > > +    if (!mc->cpu_index_to_instance_props) {
> > > +        error_report("CPUs to NUMA node mapping isn't supported");
> > > +        exit(1);
> > > +    }  
> > 
> > The error message sounds very confusing me. Maybe this could
> > become just: "NUMA is not supported by the %s machine-type"?
> If I replace this specific error message with a generic one and do
> the same in 5/24, it will be harder for us/user to figure out
> where exactly error happened.

I don't think we need to change the message in 5/24 if we change
this one.

> 
> Would be following clearer:
> "option -numa node,cpus= is not supported by the %s machine-type"

It would work if this was really the case. But the error message
is unconditional here, appearing even if cpus= is not set:

  $ qemu-system-x86_64 -m 1G -smp 1 -numa node,mem=1G -machine none
  qemu-system-x86_64: -numa node,mem=1G: CPUs to NUMA node mapping isn't supported

-- 
Eduardo

Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Igor Mammedov 8 years, 9 months ago
On Wed, 3 May 2017 14:31:09 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Wed, May 03, 2017 at 06:19:50PM +0200, Igor Mammedov wrote:
> > On Wed, 3 May 2017 12:04:29 -0300
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> >   
> > > On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:  
> > > > Default node mapping initialization already checks that board
> > > > supports cpu_index to node mapping and refuses to start if
> > > > it's not supported. Do the same for explicitly provided
> > > > mapping "-numa node,cpus=..."
> > > > 
> > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > > ---
> > > >  numa.c | 13 ++++++++++---
> > > >  1 file changed, 10 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/numa.c b/numa.c
> > > > index ab1661d..b517870 100644
> > > > --- a/numa.c
> > > > +++ b/numa.c
> > > > @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
> > > >      return -1;
> > > >  }
> > > >  
> > > > -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> > > > +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> > > > +                            QemuOpts *opts, Error **errp)
> > > >  {
> > > >      uint16_t nodenr;
> > > >      uint16List *cpus = NULL;
> > > > +    MachineClass *mc = MACHINE_GET_CLASS(ms);
> > > >  
> > > >      if (node->has_nodeid) {
> > > >          nodenr = node->nodeid;
> > > > @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> > > >          return;
> > > >      }
> > > >  
> > > > +    if (!mc->cpu_index_to_instance_props) {
> > > > +        error_report("CPUs to NUMA node mapping isn't supported");
> > > > +        exit(1);
> > > > +    }    
> > > 
> > > The error message sounds very confusing me. Maybe this could
> > > become just: "NUMA is not supported by the %s machine-type"?  
> > If I replace this specific error message with a generic one and do
> > the same in 5/24, it will be harder for us/user to figure out
> > where exactly error happened.  
> 
> I don't think we need to change the message in 5/24 if we change
> this one.
ok

> > 
> > Would be following clearer:
> > "option -numa node,cpus= is not supported by the %s machine-type"  
> 
> It would work if this was really the case. But the error message
> is unconditional here, appearing even if cpus= is not set:
> 
>   $ qemu-system-x86_64 -m 1G -smp 1 -numa node,mem=1G -machine none
>   qemu-system-x86_64: -numa node,mem=1G: CPUs to NUMA node mapping isn't supported
I'll change error message as you suggested before.


Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by Andrew Jones 8 years, 9 months ago
On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:
> Default node mapping initialization already checks that board
> supports cpu_index to node mapping and refuses to start if
> it's not supported. Do the same for explicitly provided
> mapping "-numa node,cpus=..."
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  numa.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/numa.c b/numa.c
> index ab1661d..b517870 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
>      return -1;
>  }
>  
> -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> +                            QemuOpts *opts, Error **errp)
>  {
>      uint16_t nodenr;
>      uint16List *cpus = NULL;
> +    MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
>      if (node->has_nodeid) {
>          nodenr = node->nodeid;
> @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>          return;
>      }
>  
> +    if (!mc->cpu_index_to_instance_props) {
> +        error_report("CPUs to NUMA node mapping isn't supported");
> +        exit(1);
> +    }
>      for (cpus = node->cpus; cpus; cpus = cpus->next) {
>          if (cpus->value >= max_cpus) {
>              error_setg(errp,
> @@ -215,6 +221,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>  static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
>  {
>      NumaOptions *object = NULL;
> +    MachineState *ms = opaque;
>      Error *err = NULL;
>  
>      {
> @@ -229,7 +236,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
>  
>      switch (object->type) {
>      case NUMA_OPTIONS_TYPE_NODE:
> -        numa_node_parse(&object->u.node, opts, &err);
> +        numa_node_parse(ms, &object->u.node, opts, &err);
>          if (err) {
>              goto end;
>          }
> @@ -303,7 +310,7 @@ void parse_numa_opts(MachineState *ms)
>          numa_info[i].node_cpu = bitmap_new(max_cpus);
>      }
>  
> -    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
> +    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
>          exit(1);
>      }
>  
> -- 
> 2.7.4
>

With Eduardo's error message change

Reviewed-by: Andrew Jones <drjones@redhat.com>

Re: [Qemu-devel] [PATCH v2 09/24] numa: add check that board supports cpu_index to node mapping
Posted by David Gibson 8 years, 9 months ago
On Wed, May 03, 2017 at 02:57:03PM +0200, Igor Mammedov wrote:
> Default node mapping initialization already checks that board
> supports cpu_index to node mapping and refuses to start if
> it's not supported. Do the same for explicitly provided
> mapping "-numa node,cpus=..."
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Makes sense in the series at present, although it might be obsoleted
by other suggested changes.

> ---
>  numa.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/numa.c b/numa.c
> index ab1661d..b517870 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -140,10 +140,12 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp)
>      return -1;
>  }
>  
> -static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
> +static void numa_node_parse(MachineState *ms, NumaNodeOptions *node,
> +                            QemuOpts *opts, Error **errp)
>  {
>      uint16_t nodenr;
>      uint16List *cpus = NULL;
> +    MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
>      if (node->has_nodeid) {
>          nodenr = node->nodeid;
> @@ -162,6 +164,10 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>          return;
>      }
>  
> +    if (!mc->cpu_index_to_instance_props) {
> +        error_report("CPUs to NUMA node mapping isn't supported");
> +        exit(1);
> +    }
>      for (cpus = node->cpus; cpus; cpus = cpus->next) {
>          if (cpus->value >= max_cpus) {
>              error_setg(errp,
> @@ -215,6 +221,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>  static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
>  {
>      NumaOptions *object = NULL;
> +    MachineState *ms = opaque;
>      Error *err = NULL;
>  
>      {
> @@ -229,7 +236,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
>  
>      switch (object->type) {
>      case NUMA_OPTIONS_TYPE_NODE:
> -        numa_node_parse(&object->u.node, opts, &err);
> +        numa_node_parse(ms, &object->u.node, opts, &err);
>          if (err) {
>              goto end;
>          }
> @@ -303,7 +310,7 @@ void parse_numa_opts(MachineState *ms)
>          numa_info[i].node_cpu = bitmap_new(max_cpus);
>      }
>  
> -    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
> +    if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
>          exit(1);
>      }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson