[v2,2/2] memory-device: break the loop if tmp exceed the hinted range
diff mbox series

Message ID 20190730003740.20694-3-richardw.yang@linux.intel.com
State New
Headers show
Series
  • refine memory_device_get_free_addr
Related show

Commit Message

Wei Yang July 30, 2019, 12:37 a.m. UTC
The memory-device list built by memory_device_build_list is ordered by
its address, this means if the tmp range exceed the hinted range, all
the following range will not overlap with it.

And this won't change default pc-dimm mapping and address assignment stay
the same as before this change.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 hw/mem/memory-device.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Hildenbrand July 30, 2019, 7:38 a.m. UTC | #1
On 30.07.19 02:37, Wei Yang wrote:
> The memory-device list built by memory_device_build_list is ordered by
> its address, this means if the tmp range exceed the hinted range, all
> the following range will not overlap with it.
> 
> And this won't change default pc-dimm mapping and address assignment stay
> the same as before this change.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  hw/mem/memory-device.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
> index df3261b32a..df4e338b83 100644
> --- a/hw/mem/memory-device.c
> +++ b/hw/mem/memory-device.c
> @@ -180,6 +180,8 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
>                  range_make_empty(&new);
>                  break;
>              }
> +        } else if (range_lob(&tmp) > range_upb(&new)) {
> +            break;
>          }
>      }
>  
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
Igor Mammedov July 30, 2019, 9:30 a.m. UTC | #2
On Tue, 30 Jul 2019 08:37:40 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:

> The memory-device list built by memory_device_build_list is ordered by
> its address, this means if the tmp range exceed the hinted range, all
> the following range will not overlap with it.
> 
> And this won't change default pc-dimm mapping and address assignment stay
> the same as before this change.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/mem/memory-device.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
> index df3261b32a..df4e338b83 100644
> --- a/hw/mem/memory-device.c
> +++ b/hw/mem/memory-device.c
> @@ -180,6 +180,8 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
>                  range_make_empty(&new);
>                  break;
>              }
> +        } else if (range_lob(&tmp) > range_upb(&new)) {
> +            break;
>          }
>      }
>

Patch
diff mbox series

diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index df3261b32a..df4e338b83 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -180,6 +180,8 @@  static uint64_t memory_device_get_free_addr(MachineState *ms,
                 range_make_empty(&new);
                 break;
             }
+        } else if (range_lob(&tmp) > range_upb(&new)) {
+            break;
         }
     }