Skip to contentSkip to conversation

NUMA: Replace MAX_NODES with nb_numa_nodes in for loop

PATCH In review Dou Liyang 3 participants 3 messages Aug 22, 2017

lore
Share & tools
lore

Dou Liyang

author
#0 lore raw

PATCH 1/1 NUMA: Replace MAX_NODES with nb_numa_nodes in for loop

In QEMU, the number of the NUMA nodes is determined by parse_numa_opts(). Then, QEMU uses it for iteration, for example:
for (i = 0; i < nb_numa_nodes; i++)

However, in memory_region_allocate_system_memory(), it uses MAX_NODES not nb_numa_nodes.

So, replace MAX_NODES with nb_numa_nodes to keep code consistency and reduce the loop times.

---
 numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
numa.c +1 -1
index e32af04..5f2916d 100644
@@ -567,7 +567,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
     }
 
     memory_region_init(mr, owner, name, ram_size);
-    for (i = 0; i < MAX_NODES; i++) {
+    for (i = 0; i < nb_numa_nodes; i++) {
         uint64_t size = numa_info[i].node_mem;
         HostMemoryBackend *backend = numa_info[i].node_memdev;
         if (!backend) {
Signature · 1 line
2.5.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Tue, 22 Aug 2017 15:45:36 +0800 Dou Liyang <[email protected]> wrote:

In QEMU, the number of the NUMA nodes is determined by parse_numa_opts(). Then, QEMU uses it for iteration, for example:
for (i = 0; i < nb_numa_nodes; i++)

However, in memory_region_allocate_system_memory(), it uses MAX_NODES not nb_numa_nodes.

So, replace MAX_NODES with nb_numa_nodes to keep code consistency and reduce the loop times.

Quoted 17 lines
---
 numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
numa.c +1 -1
index e32af04..5f2916d 100644
@@ -567,7 +567,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
     }
 
     memory_region_init(mr, owner, name, ram_size);
-    for (i = 0; i < MAX_NODES; i++) {
+    for (i = 0; i < nb_numa_nodes; i++) {
         uint64_t size = numa_info[i].node_mem;
         HostMemoryBackend *backend = numa_info[i].node_memdev;
         if (!backend) {
#2 lore raw
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Tue, 22 Aug 2017 15:45:36 +0800 Dou Liyang <[email protected]> wrote:

In QEMU, the number of the NUMA nodes is determined by parse_numa_opts(). Then, QEMU uses it for iteration, for example:

   for (i = 0; i < nb_numa_nodes; i++)
Quoted 8 lines
Quoted 7 lines

However, in memory_region_allocate_system_memory(), it uses MAX_NODES not nb_numa_nodes.

So, replace MAX_NODES with nb_numa_nodes to keep code consistency and reduce the loop times.

Quoted 20 lines
Quoted 18 lines
---
  numa.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
numa.c +1 -1
index e32af04..5f2916d 100644
@@ -567,7 +567,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
      }
 
      memory_region_init(mr, owner, name, ram_size);
-    for (i = 0; i < MAX_NODES; i++) {
+    for (i = 0; i < nb_numa_nodes; i++) {
          uint64_t size = numa_info[i].node_mem;
          HostMemoryBackend *backend = numa_info[i].node_memdev;
          if (!backend) {