Skip to contentSkip to conversation

refine memory_device_get_free_addr

PATCH In review Wei Yang 7 participants 18 messages Jul 30, 2019 – Oct 14, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

v2 cover refine memory_device_get_free_addr

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

 hw/mem/memory-device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 memory-device: not necessary to use goto for the last check

We are already at the last condition check.

---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c +0 -1
index 5f2c408036..df3261b32a 100644
@@ -186,7 +186,6 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;
     }
 out:
     g_slist_free(list);
Signature · 1 line
2.17.1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 24 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c index renamed from hw/mem/memory-device.c +0 -0

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c static uint64_t · line 190

Quoted 5 lines
hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another remaining "goto out" path?

Thanks,
Star

Quoted 6 lines
hw/mem/memory-device.c +0 -0
     }
 out:
     g_slist_free(list);

--
2.17.1

author
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 19 lines · Star
Quoted 19 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 13 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 10 lines
hw/mem/memory-device.c index renamed from hw/mem/memory-device.c +0 -0

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another remaining "goto out" path?

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is propagated.

Do I miss something?

Quoted 10 lines

Thanks,
Star

Quoted 6 lines
hw/mem/memory-device.c +0 -0
     }
 out:
     g_slist_free(list);

--
2.17.1

Signature · 2 lines
Wei Yang
Help you, Help me
#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 42 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 12 lines · Star
Quoted 12 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

Quoted 8 lines

hw/mem/memory-device.c

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c +0 -0

index

Quoted 11 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 9 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

Quoted 8 lines

remaining "goto out" path?

Quoted 1 line

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is propagated.

Do I miss something?

Yes, you are right. Currently, the caller is checking errp, but not the returned address, so there should be no issue.
But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

Thanks,
Star

Quoted 15 lines
Quoted 11 lines

Thanks,
Star

Quoted 6 lines
hw/mem/memory-device.c +0 -0
     }
 out:
     g_slist_free(list);

--
2.17.1

--
Wei Yang
Help you, Help me

author
#5 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 45 lines · Star
Quoted 45 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 12 lines · Star
Quoted 12 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

Quoted 8 lines

hw/mem/memory-device.c

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c +0 -0

index

Quoted 11 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 9 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

remaining "goto out" path?

Quoted 1 line
Quoted 9 lines
Quoted 5 lines

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is propagated.

Do I miss something?

Yes, you are right. Currently, the caller is checking errp, but not the returned address, so there should be no issue.
But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

You may have some point.

Let's see whether others have the same taste, or we can refine it separately.

Quoted 18 lines

Thanks,
Star

Quoted 15 lines
Quoted 11 lines

Thanks,
Star

Quoted 6 lines
hw/mem/memory-device.c +0 -0
     }
 out:
     g_slist_free(list);

--
2.17.1

--
Wei Yang
Help you, Help me

Signature · 2 lines
Wei Yang
Help you, Help me
#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 52 lines · Wei Yang
Quoted 51 lines · Star
Quoted 50 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 12 lines · Star
Quoted 12 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

Quoted 8 lines

hw/mem/memory-device.c

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c +0 -0

index

Quoted 11 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 9 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

remaining "goto out" path?

Quoted 1 line

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is propagated.

Do I miss something?

Quoted 8 lines
Quoted 3 lines

Yes, you are right. Currently, the caller is checking errp, but not the returned address, so there should be no issue.
But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

You may have some point.

Let's see whether others have the same taste, or we can refine it separately.

I don't think that's necessary (callers really should check for errors before using the return values), but I would also not object to that change.

Signature · 3 lines
Thanks,

David / dhildenb
author
#7 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 57 lines · David Hildenbrand
Quoted 56 lines · Wei Yang
Quoted 54 lines · Star
Quoted 42 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 12 lines · Star
Quoted 12 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

We are already at the last condition check.

Quoted 8 lines

hw/mem/memory-device.c

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory-device.c +0 -0

index

Quoted 11 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 9 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -1
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space for "
                    "memory device - memory fragmented due to alignments");
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

Quoted 8 lines

remaining "goto out" path?

Quoted 1 line

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is propagated.

Do I miss something?

Yes, you are right. Currently, the caller is checking errp, but not the returned address, so there should be no issue.
But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

Quoted 8 lines
Quoted 4 lines

You may have some point.

Let's see whether others have the same taste, or we can refine it separately.

I don't think that's necessary (callers really should check for errors before using the return values), but I would also not object to that change.

In case there is no strong requirement to refactor the code. I would leave it here.

Quoted 5 lines
Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Wei Yang
Help you, Help me
#8 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 87 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Monday, August 19, 2019 10:39 AM
To: David Hildenbrand <[email protected]>
Cc: Wei Yang <[email protected]>; Zeng, Star <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 8 lines · David Hildenbrand
Quoted 7 lines · Wei Yang
Quoted 6 lines · Star
Quoted 6 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected];

[email protected];

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

[email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

On Thu, Aug 08, 2019 at 01:42:14AM +0000, Zeng, Star wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not

necessary

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

to use goto for the last check

We are already at the last condition check.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hw/mem/memory-

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory- renamed from hw/mem/memory-device.c +0 -0

device.c

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

index

Quoted 7 lines

hw/mem/memory-device.c static uint64_t · line 188

Quoted 7 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -0
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space

for "

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/mem/memory-device.c static uint64_t · line 189

Quoted 1 line
hw/mem/memory-device.c +0 -0
                    "memory device - memory fragmented due to

alignments");

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 1 line
hw/mem/memory-device.c +0 -1
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

remaining "goto out" path?

Quoted 1 line

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is

propagated.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Do I miss something?

Yes, you are right. Currently, the caller is checking errp, but not the

returned address, so there should be no issue.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

You may have some point.

Let's see whether others have the same taste, or we can refine it

separately.

Quoted 2 lines
Quoted 1 line
Quoted 6 lines
Quoted 3 lines

I don't think that's necessary (callers really should check for errors before using the return values), but I would also not object to that change.

In case there is no strong requirement to refactor the code. I would leave it here.

It was just my suggestion. I am fine with any preference you and other experts have.

Thanks,
Star

Quoted 10 lines
Quoted 6 lines

--

Thanks,

David / dhildenb

--
Wei Yang
Help you, Help me

author
#9 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 87 lines · Star
Quoted 87 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Monday, August 19, 2019 10:39 AM
To: David Hildenbrand <[email protected]>
Cc: Wei Yang <[email protected]>; Zeng, Star <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

Quoted 8 lines · David Hildenbrand
Quoted 7 lines · Wei Yang
Quoted 6 lines · Star
Quoted 6 lines

-----Original Message-----
From: Wei Yang [mailto:[email protected]]
Sent: Thursday, August 8, 2019 10:13 AM
To: Zeng, Star <[email protected]>
Cc: Wei Yang <[email protected]>; [email protected]; [email protected];

[email protected];

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

[email protected]
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check

On Thu, Aug 08, 2019 at 01:42:14AM +0000, Zeng, Star wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Wei Yang
Sent: Tuesday, July 30, 2019 8:38 AM
To: [email protected]
Cc: [email protected]; [email protected]; Wei Yang <[email protected]>; [email protected]
Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not

necessary

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

to use goto for the last check

We are already at the last condition check.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hw/mem/memory-

Quoted 8 lines
---
 hw/mem/memory-device.c | 1 -
 1 file changed, 1 deletion(-)
hw/mem/memory- renamed from hw/mem/memory-device.c +0 -0

device.c

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

index

Quoted 7 lines

hw/mem/memory-device.c static uint64_t · line 188

Quoted 7 lines

5f2c408036..df3261b32a 100644

hw/mem/memory-device.c +0 -0
@@ -186,7 +186,6 @@ static uint64_t
 memory_device_get_free_addr(MachineState *ms,
     if (!range_contains_range(&as, &new)) {
         error_setg(errp, "could not find position in guest address space

for "

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hw/mem/memory-device.c static uint64_t · line 189

Quoted 1 line
hw/mem/memory-device.c +0 -0
                    "memory device - memory fragmented due to

alignments");

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

hw/mem/memory-device.c static uint64_t · line 190

Quoted 1 line
hw/mem/memory-device.c +0 -1
-        goto out;

Is it better to return 0 (or set new_addr to 0) for this error path and another

remaining "goto out" path?

Quoted 1 line

I may not get your point.

We set errp which is handled in its caller. By doing so, the error is

propagated.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Do I miss something?

Yes, you are right. Currently, the caller is checking errp, but not the

returned address, so there should be no issue.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

But when you see other error paths, you will find they all return 0. To be aligned (return 0 when error), so just suggest also returning 0 for these two "goto out" error path. :)

You may have some point.

Let's see whether others have the same taste, or we can refine it

separately.

Quoted 2 lines
Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

I don't think that's necessary (callers really should check for errors before using the return values), but I would also not object to that change.

In case there is no strong requirement to refactor the code. I would leave it here.

It was just my suggestion. I am fine with any preference you and other experts have.

Thanks

Quoted 13 lines

Thanks,
Star

Quoted 10 lines
Quoted 6 lines

--

Thanks,

David / dhildenb

--
Wei Yang
Help you, Help me

Signature · 2 lines
Wei Yang
Help you, Help me
author
#10 lore raw

PATCH v2 2/2 memory-device: break the loop if tmp exceed the hinted range

In reply to Wei Yang

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.

---
 hw/mem/memory-device.c | 2 ++
 1 file changed, 2 insertions(+)
hw/mem/memory-device.c +2 -0
index df3261b32a..df4e338b83 100644
@@ -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;
         }
     }
 
Signature · 1 line
2.17.1
Reviewed-by on v2 2/2
#11 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] memory-device: break the loop if tmp exceed the hinted range

Quoted 18 lines · Wei Yang

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.

---
 hw/mem/memory-device.c | 2 ++
 1 file changed, 2 insertions(+)
hw/mem/memory-device.c +0 -0
index df3261b32a..df4e338b83 100644

hw/mem/memory-device.c static uint64_t memory_device_get_free_addr(MachineState *ms, · line 187

Quoted 8 lines
hw/mem/memory-device.c +2 -0
@@ -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;
         }
     }
 
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v2 2/2
#12 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] memory-device: break the loop if tmp exceed the hinted range

In reply to Wei Yang
Quoted 8 lines · On Tue, 30 Jul 2019 08:37:40 +0800 Wei Yang <[email protected]>…

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.

Quoted 17 lines
---
 hw/mem/memory-device.c | 2 ++
 1 file changed, 2 insertions(+)
hw/mem/memory-device.c +2 -0
index df3261b32a..df4e338b83 100644
@@ -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;
         }
     }
 
#13 lore raw
In reply to Wei Yang
Quoted 10 lines · Wei Yang

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Quoted 7 lines

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

hw/mem/memory-device.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

Would someone take this patch set?

Quoted 3 lines
Signature · 1 line
2.17.1
Signature · 2 lines
Wei Yang
Help you, Help me
#14 lore raw
Quoted 15 lines · Wei Yang
Quoted 14 lines · Wei Yang

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

Quoted 5 lines
Quoted 3 lines

hw/mem/memory-device.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

Would someone take this patch set?

yes looks good to me too.
Eduardo?

Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.17.1
Signature · 2 lines
Wei Yang
Help you, Help me
author
#15 lore raw
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Wei Yang
Quoted 14 lines · Wei Yang

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

hw/mem/memory-device.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

Would someone take this patch set?

yes looks good to me too.
Eduardo?

Hmm... I don't see this any where. May I ask the status?

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.17.1
Signature · 2 lines
Wei Yang
Help you, Help me
Signature · 2 lines
Wei Yang
Help you, Help me
#16 lore raw
Quoted 21 lines · Wei Yang
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Wei Yang
Quoted 17 lines · Wei Yang

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

hw/mem/memory-device.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Would someone take this patch set?

yes looks good to me too.
Eduardo?

Hmm... I don't see this any where. May I ask the status?

Sorry, I hadn't seen Michael's message. Queued on machine-next. Thanks!

Signature · 1 line
Eduardo
author
#17 lore raw
Quoted 24 lines · Eduardo Habkost
Quoted 23 lines · Wei Yang
Quoted 22 lines · Michael S. Tsirkin
Quoted 20 lines · Wei Yang
Quoted 10 lines · Wei Yang

When we iterate the memory-device list to get the available range, it is not necessary to iterate the whole list.

1) no more overlap for hinted range if tmp exceed it

v2:
* remove #2 as suggested by Igor and David
* add some comment to inform address assignment stay the same as before this change

Quoted 7 lines

Wei Yang (2):
memory-device: not necessary to use goto for the last check
memory-device: break the loop if tmp exceed the hinted range

hw/mem/memory-device.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

Would someone take this patch set?

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

yes looks good to me too.
Eduardo?

Hmm... I don't see this any where. May I ask the status?

Sorry, I hadn't seen Michael's message. Queued on machine-next. Thanks!

Thanks~ have a nice day.

Quoted 2 lines
Signature · 1 line
Eduardo
Signature · 2 lines
Wei Yang
Help you, Help me