Skip to contentSkip to conversation

migration: calculate expected_downtime with ram_bytes_remaining()

PATCH Superseded Balamuruhan S 3 participants 8 messages Mar 31, 2018 – Apr 10, 2018

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: calculate expected_downtime with ram_bytes_remaining()

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index 58bd382730..4e43dc4f92 100644
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;
     }
 
     qemu_file_reset_rate_limit(s->to_dst_file);
Signature · 1 line
2.14.3
#1 lore raw
Quoted 13 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +0 -0
index 58bd382730..4e43dc4f92 100644

migration/migration.c static void migration_update_counters(MigrationState *s, · line 2248

Quoted 6 lines
migration/migration.c +1 -2
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;

This field was removed in e4ed1541ac ("savevm: New save live migration
method: pending", 2012-12-20), in which remaing RAM was used.

And it was added back in 90f8ae724a ("migration: calculate expected_downtime", 2013-02-22), in which dirty rate was used.

However I didn't find a clue on why we changed from using remaining RAM to using dirty rate... So I'll leave this question to Juan.

Besides, I'm a bit confused on when we'll want such a value. AFAIU precopy is mostly used by setting up the target downtime before hand, so we should already know the downtime before hand. Then why we want to observe such a thing?

Thanks,

Signature · 1 line
Peter Xu
author
#2 lore raw
Quoted 28 lines · Peter Xu
Quoted 13 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +0 -0
index 58bd382730..4e43dc4f92 100644

migration/migration.c static void · line 2249

Quoted 7 lines
migration/migration.c +1 -2
@@ -2245,8 +2245,7 @@ static void 
 migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;

This field was removed in e4ed1541ac ("savevm: New save live migration
method: pending", 2012-12-20), in which remaing RAM was used.

And it was added back in 90f8ae724a ("migration: calculate expected_downtime", 2013-02-22), in which dirty rate was used.

Quoted 7 lines

However I didn't find a clue on why we changed from using remaining RAM to using dirty rate... So I'll leave this question to Juan.

Besides, I'm a bit confused on when we'll want such a value. AFAIU precopy is mostly used by setting up the target downtime before hand, so we should already know the downtime before hand. Then why we want to observe such a thing?

Thanks Peter Xu for reviewing,

I tested precopy migration with 16M hugepage backed ppc guest and granularity of page size in migration is 4K so any page dirtied would result in 4096 pages to be transmitted again, this led for migration to continue endless,

default migrate_parameters:
downtime-limit: 300 milliseconds

info migrate:
expected downtime: 1475 milliseconds

Migration status: active
total time: 130874 milliseconds
expected downtime: 1475 milliseconds
setup: 3475 milliseconds
transferred ram: 18197383 kbytes
throughput: 866.83 mbps
remaining ram: 376892 kbytes
total ram: 8388864 kbytes
duplicate: 1678265 pages
skipped: 0 pages
normal: 4536795 pages
normal bytes: 18147180 kbytes
dirty sync count: 6
page size: 4 kbytes
dirty pages rate: 39044 pages

In order to complete migration I configured downtime-limit to 1475 milliseconds but still migration was endless. Later calculated expected downtime by remaining ram 376892 Kbytes / 866.83 mbps yeilded 3478.34 milliseconds and configuring it as downtime-limit succeeds the migration to complete. This led to the conclusion that expected downtime is not accurate.

Regards,
Balamuruhan S

Quoted 2 lines

Thanks,

#3 lore raw
Quoted 68 lines · On Tue, Apr 03, 2018 at 11:00:00PM +0530, bala24 wrote:
Quoted 29 lines · Peter Xu
Quoted 14 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size,
using ram_bytes_remaining would yeild it correct.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +0 -0
index 58bd382730..4e43dc4f92 100644

migration/migration.c static void · line 2249

Quoted 7 lines
migration/migration.c +1 -2
@@ -2245,8 +2245,7 @@ static void
 migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;

This field was removed in e4ed1541ac ("savevm: New save live migration
method: pending", 2012-12-20), in which remaing RAM was used.

And it was added back in 90f8ae724a ("migration: calculate expected_downtime", 2013-02-22), in which dirty rate was used.

Quoted 7 lines

However I didn't find a clue on why we changed from using remaining RAM to using dirty rate... So I'll leave this question to Juan.

Besides, I'm a bit confused on when we'll want such a value. AFAIU precopy is mostly used by setting up the target downtime before hand, so we should already know the downtime before hand. Then why we want to observe such a thing?

Thanks Peter Xu for reviewing,

I tested precopy migration with 16M hugepage backed ppc guest and granularity
of page size in migration is 4K so any page dirtied would result in 4096 pages
to be transmitted again, this led for migration to continue endless,

default migrate_parameters:
downtime-limit: 300 milliseconds

info migrate:
expected downtime: 1475 milliseconds

Migration status: active
total time: 130874 milliseconds
expected downtime: 1475 milliseconds
setup: 3475 milliseconds
transferred ram: 18197383 kbytes
throughput: 866.83 mbps
remaining ram: 376892 kbytes
total ram: 8388864 kbytes
duplicate: 1678265 pages
skipped: 0 pages
normal: 4536795 pages
normal bytes: 18147180 kbytes
dirty sync count: 6
page size: 4 kbytes
dirty pages rate: 39044 pages

Quoted 6 lines

In order to complete migration I configured downtime-limit to 1475 milliseconds but still migration was endless. Later calculated expected downtime by remaining ram 376892 Kbytes / 866.83 mbps yeilded 3478.34 milliseconds and configuring it as downtime-limit succeeds the migration to complete. This led to the conclusion that expected downtime is not accurate.

Hmm, thanks for the information. I'd say your calculation seems reasonable to me: it shows how long time will it need if we stop the VM now on source immediately and migrate the rest. However Juan might have an explanation on existing algorithm which I would like to know too. So still I'll put aside the "which one is better" question.

For your use case, you can have a look on either of below way to have a converged migration:

- auto-converge: that's a migration capability that throttles CPU usage of guests

- postcopy: that'll let you start the destination VM even without transferring all the RAMs before hand

Either of the technique can be configured via "migrate_set_capability" HMP command or "migrate-set-capabilities" QMP command (some googling would show detailed steps). And, either of above should help you to migrate successfully in this hard-to-converge scenario, instead of your current way (observing downtime, set downtime).

Meanwhile, I'm thinking whether instead of observing the downtime in real time, whether we should introduce a command to stop the VM immediately to migrate the rest when we want, or, a new parameter to current "migrate" command.

Signature · 1 line
Peter Xu
#4 lore raw
In reply to Peter Xu
Quoted 9 lines · Peter Xu
Quoted 8 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 14 lines

migration/migration.c static void migration_update_counters(MigrationState *s, · line 2248

Quoted 11 lines
migration/migration.c +1 -2
index 58bd382730..4e43dc4f92 100644
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;

This field was removed in e4ed1541ac ("savevm: New save live migration
method: pending", 2012-12-20), in which remaing RAM was used.

Unrelated O:-)

Quoted 2 lines

And it was added back in 90f8ae724a ("migration: calculate expected_downtime", 2013-02-22), in which dirty rate was used.

We didn't want to update the field if there haven't been enough activity.

Quoted 7 lines

However I didn't find a clue on why we changed from using remaining RAM to using dirty rate... So I'll leave this question to Juan.

Besides, I'm a bit confused on when we'll want such a value. AFAIU precopy is mostly used by setting up the target downtime before hand, so we should already know the downtime before hand. Then why we want to observe such a thing?

What that field means is how much time the system needs to send everything that is pending.

I.e. if expected_downtime = 2seconds, it means that with current dirty rate, if we set a downtime of 2 or bigger it is going to finish migration.

It is a help for upper layers to decide that:
- they want a 1second downtime
- system calculates with current load that they need a 2second downtime

So they can decide:
- change the downtime to 2seconds (easy)
- change the apps running on the guest to dirty less memory (It dependes on the guest, app, etc).

I don't know if anyone is using it at all.

Later, Juan.

Reviewed-by on v1 1/1
#5 lore raw
In reply to Balamuruhan S
Quoted 4 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

See my other mail on the thread, my understanding is that your change is corret (TM).

Thanks, Juan.

Quoted 18 lines
---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index 58bd382730..4e43dc4f92 100644
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;
     }
 
     qemu_file_reset_rate_limit(s->to_dst_file);
#6 lore raw
Quoted 10 lines · Juan Quintela
Quoted 4 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

See my other mail on the thread, my understanding is that your change is corret (TM).

Juan, Please help to merge it.

Regards,
Bala

Quoted 22 lines

Thanks, Juan.

Quoted 18 lines
---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index 58bd382730..4e43dc4f92 100644
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;
     }
 
     qemu_file_reset_rate_limit(s->to_dst_file);
#7 lore raw
Quoted 5 lines · Balamuruhan S
Quoted 4 lines · Juan Quintela
Quoted 3 lines · Balamuruhan S

expected_downtime value is not accurate with dirty_pages_rate * page_size, using ram_bytes_remaining would yeild it correct.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

See my other mail on the thread, my understanding is that your change is corret (TM).

Juan, Please help to merge it.

Sorry for asking it as during discussion going on, but the reason is currently postcopy migration for HP backed P8 guest from P8 -> P9 is broken and to use precopy with appropriate downtime value we need this patch to be backported to distros that is to be released soon.

Quoted 26 lines

Regards,
Bala

Quoted 22 lines

Thanks, Juan.

Quoted 18 lines
---
 migration/migration.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/migration.c +1 -2
index 58bd382730..4e43dc4f92 100644
@@ -2245,8 +2245,7 @@ static void migration_update_counters(MigrationState *s,
      * recalculate. 10000 is a small enough number for our purposes
      */
     if (ram_counters.dirty_pages_rate && transferred > 10000) {
-        s->expected_downtime = ram_counters.dirty_pages_rate *
-            qemu_target_page_size() / bandwidth;
+        s->expected_downtime = ram_bytes_remaining() / bandwidth;
     }
 
     qemu_file_reset_rate_limit(s->to_dst_file);