Skip to contentSkip to conversation

numa: stop abusing numa_mem_supported

PATCH In review Igor Mammedov 5 participants 13 messages Dec 12, 2019 – Dec 20, 2019

lore
Share & tools
lore
#0 lore raw

cover numa: stop abusing numa_mem_supported

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

CC Eduardo Habkost <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Tao Xu <[email protected]>

Igor Mammedov (2):
numa: remove not needed check
numa: properly check if numa is supported

 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 hw/core/numa.c    | 7 +------
 3 files changed, 3 insertions(+), 9 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 numa: remove not needed check

Currently parse_numa_node() is always called from already numa enabled context.
Drop unnecessary check if numa is supported.

---
 hw/core/numa.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
hw/core/numa.c +1 -6
index e3332a9..19f082d 100644
@@ -83,10 +83,6 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
         return;
     }
 
-    if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) {
-        error_setg(errp, "NUMA is not supported by this machine-type");
-        return;
-    }
     for (cpus = node->cpus; cpus; cpus = cpus->next) {
         CpuInstanceProperties props;
         if (cpus->value >= max_cpus) {
@@ -178,9 +174,8 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp)
 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
 {
     Error *err = NULL;
-    MachineClass *mc = MACHINE_GET_CLASS(ms);
 
-    if (!mc->numa_mem_supported) {
+    if (!ms->numa_state) {
         error_setg(errp, "NUMA is not supported by this machine-type");
         goto end;
     }
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/2 numa: properly check if numa is supported

In reply to Igor Mammedov

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field is set to true for them.

But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.

Fix it:
- by using previously used condition

      !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id

the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk

Fixes aa57020774b690a22be72453b8e91c9b5a68c516

---
CC: Radoslaw Biernacki <[email protected]>
CC: Peter Maydell <[email protected]>
CC: Leif Lindholm <[email protected]>
CC: [email protected]
CC: [email protected]

 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
hw/arm/sbsa-ref.c +0 -1
index 27046cc..c6261d4 100644
@@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
     mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
     mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
-    mc->numa_mem_supported = true;
 }
 
 static const TypeInfo sbsa_ref_info = {
hw/core/machine.c +2 -2
index 1689ad3..aa63231 100644
@@ -958,7 +958,7 @@ static void machine_initfn(Object *obj)
                                         NULL);
     }
 
-    if (mc->numa_mem_supported) {
+    if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
         ms->numa_state = g_new0(NumaState, 1);
     }
 
@@ -1102,7 +1102,7 @@ void machine_run_board_init(MachineState *machine)
 {
     MachineClass *machine_class = MACHINE_GET_CLASS(machine);
 
-    if (machine_class->numa_mem_supported) {
+    if (machine->numa_state) {
         numa_complete_configuration(machine);
         if (machine->numa_state->num_nodes) {
             machine_numa_finish_cpu_init(machine);
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH 2/2] numa: properly check if numa is supported

Quoted 48 lines · Igor Mammedov

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field is set to true for them.

But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.

Fix it:
- by using previously used condition !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk

Fixes aa57020774b690a22be72453b8e91c9b5a68c516

---
CC: Radoslaw Biernacki <[email protected]>
CC: Peter Maydell <[email protected]>
CC: Leif Lindholm <[email protected]>
CC: [email protected]
CC: [email protected]

  hw/arm/sbsa-ref.c | 1 -
  hw/core/machine.c | 4 ++--
  2 files changed, 2 insertions(+), 3 deletions(-)
hw/arm/sbsa-ref.c +0 -1
index 27046cc..c6261d4 100644
@@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
      mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
      mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
      mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
-    mc->numa_mem_supported = true;
  }
 
  static const TypeInfo sbsa_ref_info = {
hw/core/machine.c +0 -0
index 1689ad3..aa63231 100644

hw/core/machine.c static void machine_initfn(Object *obj) · line 963

Quoted 7 lines
hw/core/machine.c +1 -1
@@ -958,7 +958,7 @@ static void machine_initfn(Object *obj)
                                          NULL);
      }
 
-    if (mc->numa_mem_supported) {
+    if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
          ms->numa_state = g_new0(NumaState, 1);
      }

I am wondering if @numa_mem_supported is unused here, it is unused for QEMU, because the only usage of @numa_mem_supported is to initialize @numa_state. Or there is other usage? So should it be removed from struct MachineClass?

#5 lore raw

Re: [PATCH 2/2] numa: properly check if numa is supported

Quoted 52 lines · On Fri, 13 Dec 2019 09:33:10 +0800 Tao Xu <[email protected]> wrote:
Quoted 51 lines · Igor Mammedov

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field is set to true for them.

But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.

Fix it:
- by using previously used condition !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk

Fixes aa57020774b690a22be72453b8e91c9b5a68c516

---
CC: Radoslaw Biernacki <[email protected]>
CC: Peter Maydell <[email protected]>
CC: Leif Lindholm <[email protected]>
CC: [email protected]
CC: [email protected]

  hw/arm/sbsa-ref.c | 1 -
  hw/core/machine.c | 4 ++--
  2 files changed, 2 insertions(+), 3 deletions(-)
hw/arm/sbsa-ref.c +0 -1
index 27046cc..c6261d4 100644
@@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
      mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
      mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
      mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
-    mc->numa_mem_supported = true;
  }
 
  static const TypeInfo sbsa_ref_info = {
hw/core/machine.c +0 -0
index 1689ad3..aa63231 100644
@@ -958,7 +958,7 @@ static void machine_initfn(Object *obj)
                                          NULL);
      }
 
Quoted 9 lines

hw/core/machine.c static void machine_initfn(Object *obj) · line 963

Quoted 4 lines
hw/core/machine.c +1 -1
-    if (mc->numa_mem_supported) {
+    if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
          ms->numa_state = g_new0(NumaState, 1);
      }  

I am wondering if @numa_mem_supported is unused here, it is unused for QEMU, because the only usage of @numa_mem_supported is to initialize @numa_state. Or there is other usage? So should it be removed from struct MachineClass?

You are wrong, it's not intended for numa_state initialization, read doc comment for it in include/hw/boards.h
(for full story look at commit cd5ff8333a3)

#6 lore raw

Re: [PATCH 2/2] numa: properly check if numa is supported

Quoted 64 lines · Igor Mammedov
Quoted 52 lines · On Fri, 13 Dec 2019 09:33:10 +0800 Tao Xu <[email protected]> wrote:
Quoted 51 lines · Igor Mammedov

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field is set to true for them.

But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.

Fix it:
- by using previously used condition !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk

Fixes aa57020774b690a22be72453b8e91c9b5a68c516

---
CC: Radoslaw Biernacki <[email protected]>
CC: Peter Maydell <[email protected]>
CC: Leif Lindholm <[email protected]>
CC: [email protected]
CC: [email protected]

   hw/arm/sbsa-ref.c | 1 -
   hw/core/machine.c | 4 ++--
   2 files changed, 2 insertions(+), 3 deletions(-)
hw/arm/sbsa-ref.c +0 -1
index 27046cc..c6261d4 100644
@@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
       mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
       mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
       mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
-    mc->numa_mem_supported = true;
   }
 
   static const TypeInfo sbsa_ref_info = {
hw/core/machine.c +0 -0
index 1689ad3..aa63231 100644
@@ -958,7 +958,7 @@ static void machine_initfn(Object *obj)
                                           NULL);
       }
 
Quoted 9 lines

hw/core/machine.c static void machine_initfn(Object *obj) · line 963

Quoted 4 lines
hw/core/machine.c +1 -1
-    if (mc->numa_mem_supported) {
+    if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
           ms->numa_state = g_new0(NumaState, 1);
       }

I am wondering if @numa_mem_supported is unused here, it is unused for QEMU, because the only usage of @numa_mem_supported is to initialize @numa_state. Or there is other usage? So should it be removed from struct MachineClass?

Quoted 4 lines

You are wrong, it's not intended for numa_state initialization, read doc comment for it in include/hw/boards.h
(for full story look at commit cd5ff8333a3)

I understand.

Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] numa: properly check if numa is supported

In reply to Igor Mammedov
Quoted 12 lines · Igor Mammedov

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field is set to true for them.

But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types.

Fix it:
- by using previously used condition

Quoted 7 lines
      !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id

the first time and then use MachineState::numa_state down the road to check if NUMA is supported
- dropping stray sbsa-ref chunk

Fixes aa57020774b690a22be72453b8e91c9b5a68c516

I'm queueing this and plan to submit a pull request soon.

Signature · 1 line
Eduardo
#8 lore raw
In reply to Igor Mammedov
Quoted 2 lines · On Thu, 12 Dec 2019 13:48:54 +0100 Igor Mammedov <[email protected]> wrote:

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

ping,

could someone pick it up please?

Quoted 15 lines
CC Eduardo Habkost <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Tao Xu <[email protected]>

Igor Mammedov (2):
numa: remove not needed check
numa: properly check if numa is supported

 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 hw/core/numa.c    | 7 +------
 3 files changed, 3 insertions(+), 9 deletions(-)
#9 lore raw
Quoted 9 lines · Igor Mammedov
Quoted 2 lines · On Thu, 12 Dec 2019 13:48:54 +0100 Igor Mammedov <[email protected]> wrote:

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

ping,

could someone pick it up please?

Looks more like Eduardo's thing.

Quoted 15 lines
Quoted 15 lines
CC Eduardo Habkost <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Tao Xu <[email protected]>

Igor Mammedov (2):
numa: remove not needed check
numa: properly check if numa is supported

 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 hw/core/numa.c    | 7 +------
 3 files changed, 3 insertions(+), 9 deletions(-)
#10 lore raw
Quoted 4 lines · On Thu, 19 Dec 2019 08:30:34 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov

On Thu, 12 Dec 2019 13:48:54 +0100
Igor Mammedov <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

ping,

could someone pick it up please?

Looks more like Eduardo's thing.

Yep if he is still available,
but I wasn't sure with coming winter break.

In addition, this patch will be prerequisite for disabling deprecated '-numa node,mem'
hence broadcast ping to make sure it won't get lost.

Quoted 17 lines
Quoted 16 lines
Quoted 16 lines
CC Eduardo Habkost <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Tao Xu <[email protected]>

Igor Mammedov (2):
numa: remove not needed check
numa: properly check if numa is supported

 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 hw/core/numa.c    | 7 +------
 3 files changed, 3 insertions(+), 9 deletions(-)
#11 lore raw
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Thu, 19 Dec 2019 08:30:34 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
Quoted 2 lines · On Thu, 12 Dec 2019 13:48:54 +0100 Igor Mammedov <[email protected]> wrote:

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

ping,

could someone pick it up please?

Quoted 8 lines
Quoted 1 line

Looks more like Eduardo's thing.

Yep if he is still available,
but I wasn't sure with coming winter break.

In addition, this patch will be prerequisite for disabling deprecated '-numa node,mem'
hence broadcast ping to make sure it won't get lost.

I'll take care of it (after new year).

Paolo

#12 lore raw
Quoted 17 lines · On Fri, 20 Dec 2019 14:14:58 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 16 lines · Igor Mammedov
Quoted 12 lines · On Thu, 19 Dec 2019 08:30:34 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
Quoted 2 lines · On Thu, 12 Dec 2019 13:48:54 +0100 Igor Mammedov <[email protected]> wrote:

A fix and cleanup for a mistakes that slipped by me in
aa57020774 (numa: move numa global variable nb_numa_nodes into MachineState)

ping,

could someone pick it up please?

Looks more like Eduardo's thing.

Quoted 8 lines
Quoted 6 lines

Yep if he is still available,
but I wasn't sure with coming winter break.

In addition, this patch will be prerequisite for disabling deprecated '-numa node,mem'
hence broadcast ping to make sure it won't get lost.

I'll take care of it (after new year).

It' looks like Eduardo already picked it up.
(meanwhile I'm preparing to post mem-path patch bomb with these included)

Though it would be nice is you could take a look at another series
[PATCH for-5.0 v2 0/9] q35: CPU hotplug with secure boot, part 1+2
especially 2/9 patch

Quoted 4 lines

Paolo