From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvQ9Z-0000hx-FZ for qemu-devel@nongnu.org; Fri, 13 Jun 2014 08:00:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvQ9S-0001sG-De for qemu-devel@nongnu.org; Fri, 13 Jun 2014 08:00:17 -0400 Received: from zimbra3.corp.accelance.fr ([2001:4080:204::2:8]:45507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvQ9S-0001ri-4V for qemu-devel@nongnu.org; Fri, 13 Jun 2014 08:00:10 -0400 Date: Fri, 13 Jun 2014 14:00:03 +0200 (CEST) From: Sebastian Tanase Message-ID: <967163394.17793099.1402660803135.JavaMail.root@openwide.fr> In-Reply-To: <539AD290.7000103@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH V2 5/5] cpu_exec: Print to console if the guest is late List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, peter maydell , jeremy rosen , aliguori@amazon.com, wenchaoqemu@gmail.com, quintela@redhat.com, qemu-devel@nongnu.org, mjt@tls.msk.ru, mst@redhat.com, stefanha@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, michael@walle.cc, camille begue , alex@alex.org.uk, crobinso@redhat.com, pierre lemagourou , afaerber@suse.de, rth@twiddle.net ----- Mail original ----- > De: "Paolo Bonzini" > =C3=80: "Sebastian Tanase" , qemu-devel@non= gnu.org > Cc: aliguori@amazon.com, afaerber@suse.de, rth@twiddle.net, "peter maydel= l" , > michael@walle.cc, alex@alex.org.uk, stefanha@redhat.com, lcapitulino@redh= at.com, crobinso@redhat.com, > armbru@redhat.com, wenchaoqemu@gmail.com, quintela@redhat.com, kwolf@redh= at.com, mjt@tls.msk.ru, mst@redhat.com, > "camille begue" , "pierre lemagourou" , "jeremy rosen" > > Envoy=C3=A9: Vendredi 13 Juin 2014 12:29:36 > Objet: Re: [RFC PATCH V2 5/5] cpu_exec: Print to console if the guest is = late >=20 > Il 13/06/2014 11:40, Sebastian Tanase ha scritto: > > If the align option is enabled, we print to the user whenever > > the guest clock is behind the host clock in order for he/she > > to have a hint about the actual performance. The maximum > > print interval is 2s so as not to spam the console. > > > > Signed-off-by: Sebastian Tanase > > Tested-by: Camille B=C3=A9gu=C3=A9 > > --- > > cpu-exec.c | 32 +++++++++++++++++++++++++++++++- > > 1 file changed, 31 insertions(+), 1 deletion(-) > > > > diff --git a/cpu-exec.c b/cpu-exec.c > > index 5a3bc5e..a386592 100644 > > --- a/cpu-exec.c > > +++ b/cpu-exec.c > > @@ -216,6 +216,8 @@ static void > > cpu_handle_debug_exception(CPUArchState *env) > > * oscillate around 0. > > */ > > #define VM_CLOCK_ADVANCE 3000000 > > +#define THRESHOLD_REDUCE 1.5 > > +#define MAX_DELAY_PRINT_RATE 2 > > > > static int64_t delay_host(int64_t diff_clk) > > { > > @@ -257,6 +259,29 @@ static int64_t align_clocks(int64_t diff_clk, > > int64_t *oic, CPUState *cpu) > > return diff_clk; > > } > > > > +static void print_delay(int64_t diff_clk, int64_t realtime_clock) > > +{ > > + static float threshold_delay; > > + static int64_t last_realtime_clock; > > + > > + if ((realtime_clock - last_realtime_clock) / 1000000000LL > > + >=3D MAX_DELAY_PRINT_RATE) { > > + if (-diff_clk / (float)1000000000LL > threshold_delay) { > > + threshold_delay =3D (-diff_clk / 1000000000LL) + 1; > > + printf("Warning: The guest is late by %.1f to %.1f > > seconds\n", > > + threshold_delay - 1, > > + threshold_delay); > > + } else if (-diff_clk / (float)1000000000LL < > > + (threshold_delay - THRESHOLD_REDUCE)) { > > + threshold_delay =3D (-diff_clk / 1000000000LL) + 1; > > + printf("Warning: The guest has reduced the > > delay and is now " > > + "late by %.1f to %.1f seconds\n", > > + threshold_delay - 1, > > + threshold_delay); > > + } > > + last_realtime_clock =3D realtime_clock; > > + } > > +} >=20 > Perhaps stop printing the message after the first 50-100 times? >=20 > Paolo >=20 Thank you very much for your feedback. Maybe adding a monitor command (info drift) would be better ? Then the user would not be spammed by printfs. Sebastian Tanase > > #endif /* CONFIG USER ONLY */ > > > > /* main execution loop */ > > @@ -278,6 +303,8 @@ int cpu_exec(CPUArchState *env) > > uint8_t *tc_ptr; > > uintptr_t next_tb; > > #if !(defined(CONFIG_USER_ONLY)) > > + /* Print delay control */ > > + static int64_t realtime_clock; > > /* Delay algorithm */ > > int64_t diff_clk, original_instr_counter; > > #endif > > @@ -342,9 +369,12 @@ int cpu_exec(CPUArchState *env) > > This delay includes the delay of the last cycle, so > > what we have to do is sleep until it is 0. As for the > > advance/delay we gain here, we try to fix it next time. > > */ > > + realtime_clock =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > > diff_clk =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - > > - qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + > > clocks_offset; > > + realtime_clock + clocks_offset; > > original_instr_counter =3D cpu->icount_extra + > > cpu->icount_decr.u16.low; > > + /* Print (every 2s max) if the guest is behind the host */ > > + print_delay(diff_clk, realtime_clock); > > } > > #endif > > /* prepare setjmp context for exception handling */ > > >=20 >=20