Message ID | 189d97ce396dd1b4e8b497fbd1b276086ac05cbc.1337710679.git.quintela@redhat.com |
---|---|
State | New |
Headers | show |
On 05/22/2012 09:32 PM, Juan Quintela wrote: > cheking each 64 pages is a random magic number as good as any other. s/cheking/checking > We don't want to test too many times, but on the other hand, > qemu_get_clock_ns() is not so expensive either. We want to be sure > that we spent less than 50ms (half of buffered_file timer), if we > spent more than 100ms, all the accounting got wrong. > > Signed-off-by: Juan Quintela <quintela@redhat.com> > --- > arch_init.c | 15 +++++++++++++++ > 1 files changed, 15 insertions(+), 0 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index 76a3d4e..2aa77ff 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -296,6 +296,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) > uint64_t bytes_transferred_last; > double bwidth = 0; > int ret; > + int i; > > if (stage < 0) { > memory_global_dirty_log_stop(); > @@ -335,6 +336,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) > bytes_transferred_last = bytes_transferred; > bwidth = qemu_get_clock_ns(rt_clock); > > + i = 0; > while ((ret = qemu_file_rate_limit(f)) == 0) { > int bytes_sent; > > @@ -343,6 +345,19 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) > if (bytes_sent == 0) { /* no more blocks */ > break; > } > + /* we want to check in the 1st loop, just in case it was the 1st time > + and we had to sync the dirty bitmap. > + qemu_get_clock_ns() is a bit expensive, so we only check each some > + iterations > + */ > + if ((i & 63) == 0) { > + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; > + if (t1 > 50) { /* 50ms, half buffered_file limit */ can't we use a constant ? > + printf("big delay %ld milliseconds, %d iterations\n", t1, i); printf ? Orit > + break; > + } > + } > + i++; > } > > if (ret < 0) {
Orit Wasserman <owasserm@redhat.com> wrote: > On 05/22/2012 09:32 PM, Juan Quintela wrote: >> cheking each 64 pages is a random magic number as good as any other. > s/cheking/checking Done. >> + */ >> + if ((i & 63) == 0) { >> + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; >> + if (t1 > 50) { /* 50ms, half buffered_file limit */ > can't we use a constant ? 50 is a constant already, no? Or what do you mean. >> + printf("big delay %ld milliseconds, %d iterations\n", t1, i); > printf ? This is the kind of "this shouldn't happen", but still happens, DPRINTF? Thanks, Juan.
> >> + if ((i & 63) == 0) { > >> + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; > >> + if (t1 > 50) { /* 50ms, half buffered_file limit */ > > can't we use a constant ? > > 50 is a constant already, no? Or what do you mean. I guess Orit means, #define THRESHOLD 50 if (t1 > THRESHOLD) { ... } Regards, chenwj
"(Wei-Ren Chen)" <chenwj@iis.sinica.edu.tw> wrote: >> >> + if ((i & 63) == 0) { >> >> + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; >> >> + if (t1 > 50) { /* 50ms, half buffered_file limit */ >> > can't we use a constant ? >> >> 50 is a constant already, no? Or what do you mean. > > I guess Orit means, > > #define THRESHOLD 50 > > if (t1 > THRESHOLD) { ... } Thanks, Added. Later, Juan.
diff --git a/arch_init.c b/arch_init.c index 76a3d4e..2aa77ff 100644 --- a/arch_init.c +++ b/arch_init.c @@ -296,6 +296,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) uint64_t bytes_transferred_last; double bwidth = 0; int ret; + int i; if (stage < 0) { memory_global_dirty_log_stop(); @@ -335,6 +336,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) bytes_transferred_last = bytes_transferred; bwidth = qemu_get_clock_ns(rt_clock); + i = 0; while ((ret = qemu_file_rate_limit(f)) == 0) { int bytes_sent; @@ -343,6 +345,19 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque) if (bytes_sent == 0) { /* no more blocks */ break; } + /* we want to check in the 1st loop, just in case it was the 1st time + and we had to sync the dirty bitmap. + qemu_get_clock_ns() is a bit expensive, so we only check each some + iterations + */ + if ((i & 63) == 0) { + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; + if (t1 > 50) { /* 50ms, half buffered_file limit */ + printf("big delay %ld milliseconds, %d iterations\n", t1, i); + break; + } + } + i++; } if (ret < 0) {
cheking each 64 pages is a random magic number as good as any other. We don't want to test too many times, but on the other hand, qemu_get_clock_ns() is not so expensive either. We want to be sure that we spent less than 50ms (half of buffered_file timer), if we spent more than 100ms, all the accounting got wrong. Signed-off-by: Juan Quintela <quintela@redhat.com> --- arch_init.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)