qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/3] numa: Reject configuration if CPU appears on


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH v2 2/3] numa: Reject configuration if CPU appears on multiple nodes
Date: Mon, 9 Feb 2015 17:53:15 -0200

Each CPU can appear in only one NUMA node on the NUMA config. Reject
configuration if a CPU appears in multiple nodes.

Signed-off-by: Eduardo Habkost <address@hidden>
---
 numa.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/numa.c b/numa.c
index f768434..f004a74 100644
--- a/numa.c
+++ b/numa.c
@@ -167,6 +167,31 @@ error:
     return -1;
 }
 
+static void validate_numa_cpus(void)
+{
+    int i, cpu;
+    DECLARE_BITMAP(present_cpus, MAX_CPUMASK_BITS);
+
+    bitmap_zero(present_cpus, MAX_CPUMASK_BITS);
+    for (i = 0; i < nb_numa_nodes; i++) {
+        if (bitmap_intersects(present_cpus, numa_info[i].node_cpu,
+                              MAX_CPUMASK_BITS)) {
+            bitmap_and(present_cpus, present_cpus,
+                       numa_info[i].node_cpu, MAX_CPUMASK_BITS);
+            fprintf(stderr, "CPU(s) present in multiple NUMA nodes:");
+            for (cpu = find_first_bit(present_cpus, MAX_CPUMASK_BITS);
+                cpu < MAX_CPUMASK_BITS;
+                cpu = find_next_bit(present_cpus, MAX_CPUMASK_BITS, cpu + 1)) {
+                fprintf(stderr, " %d", cpu);
+            }
+            fprintf(stderr, "\n");
+            exit(1);
+        }
+        bitmap_or(present_cpus, present_cpus,
+                  numa_info[i].node_cpu, MAX_CPUMASK_BITS);
+    }
+}
+
 void parse_numa_opts(void)
 {
     int i;
@@ -244,6 +269,8 @@ void parse_numa_opts(void)
                 set_bit(i, numa_info[i % nb_numa_nodes].node_cpu);
             }
         }
+
+        validate_numa_cpus();
     }
 }
 
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]