[Qemu-devel] [PATCH] NUMA: Replace MAX_NODES with nb_numa_nodes in for loop

Dou Liyang posted 1 patch 6 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1503387936-3483-1-git-send-email-douly.fnst@cn.fujitsu.com
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] NUMA: Replace MAX_NODES with nb_numa_nodes in for loop
Posted by Dou Liyang 6 years, 7 months ago
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.

Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
 numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/numa.c b/numa.c
index e32af04..5f2916d 100644
--- a/numa.c
+++ b/numa.c
@@ -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.5.5




Re: [Qemu-devel] [PATCH] NUMA: Replace MAX_NODES with nb_numa_nodes in for loop
Posted by Igor Mammedov 6 years, 7 months ago
On Tue, 22 Aug 2017 15:45:36 +0800
Dou Liyang <douly.fnst@cn.fujitsu.com> 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.
> 
> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  numa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/numa.c b/numa.c
> index e32af04..5f2916d 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -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) {


Re: [Qemu-devel] [PATCH] NUMA: Replace MAX_NODES with nb_numa_nodes in for loop
Posted by Philippe Mathieu-Daudé 6 years, 7 months ago
On 08/22/2017 10:20 AM, Igor Mammedov wrote:
> On Tue, 22 Aug 2017 15:45:36 +0800
> Dou Liyang <douly.fnst@cn.fujitsu.com> 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.
>>
>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
>> ---
>>   numa.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/numa.c b/numa.c
>> index e32af04..5f2916d 100644
>> --- a/numa.c
>> +++ b/numa.c
>> @@ -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) {
> 
>