qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC
@ 2012-05-09  7:22 Zhang, Yang Z
  2012-05-09 13:06 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Yang Z @ 2012-05-09  7:22 UTC (permalink / raw)
  To: 'qemu-devel@nongnu.org'
  Cc: 'Paolo Bonzini', 'aliguori@us.ibm.com'

Changes in v5:
Rebase to latest head.
Add Checking of divider, because it also can stop the update.
Fixing some bugs.

Changes in v4:
Rebase to latest head.
Changing in patch 6: 
	Set the timer to one second earlier before target alarm when AF bit is clear. In version 3, in order to solve the async between UF, AF and UIP, the timer will keep running when UF or AF are clear. This is a little ugly, especially when a userspace program is using the alarm and we cannot achieve any power saving. In this version, when the AF bit is cleared, we will set the timer to one second earlier before the alarm. With this changing, we can avoid the unnecessary timer and keep the sync between UF, AF and UIP. Please help to review the patch 6.

Changes in v3:
Rebase to latest head.
Remove the logic to update time format when DM bit changed.
Allow to migrate from old version.
Solve the async when reading UF and UIP

Changes in v2:
Add UIP check logic.
Add logic that next second tick will occur in exactly 500ms later after reset divider

Current RTC emulation uses periodic timer(2 timers per second) to update RTC clock. And it will stop CPU staying at deep C-state for long period. Our experience shows the Pkg C6 residency reduced 6% when running 64 idle guest.
The following patch stop the two periodic timer and only updating RTC clock when guest try to read it.
--- 
Yang Zhang (7):
	RTC: Remove the logic to update time format when DM bit changed
	RTC: Update the RTC clock only when reading it
	RTC: Add UIP(update in progress) check logic
	RTC: Set internal millisecond register to 500ms when reset divider
	RTC: Add RTC update-ended interrupt support
	RTC: Add alarm support
	RTC: Allow to migrate from old version

    hw/mc146818rtc.c |  617 ++++++++++++++++++++++++++++++++++++++++-------------
    1 files changed, 465 insertions(+), 152 deletions(-)

best regards
yang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC
  2012-05-09  7:22 [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC Zhang, Yang Z
@ 2012-05-09 13:06 ` Paolo Bonzini
  2012-05-10  1:41   ` Zhang, Yang Z
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2012-05-09 13:06 UTC (permalink / raw)
  To: Zhang, Yang Z
  Cc: 'aliguori@us.ibm.com', 'qemu-devel@nongnu.org'

Il 09/05/2012 09:22, Zhang, Yang Z ha scritto:
> Changes in v5:
> Rebase to latest head.
> Add Checking of divider, because it also can stop the update.
> Fixing some bugs.

At last this passes my tests, great!  There's still a few problems, but more
or less it's ok:

1) it needs rebase on top of the latest version of QEMU;

2) it doesn't pass tests/rtc-test, but that might even be a problem with
the test; I'll try to look at it.

3) the migration code is not perfect, something like this needs to be
squashed in

diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index e76c34b..026bb29 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -821,27 +821,34 @@ static int rtc_load_old(QEMUFile *f, void *opaque, int version_id)
     }
 
     qemu_get_buffer(f, s->cmos_data, sizeof(s->cmos_data));
-    /* dummy load for compatibility */
-    qemu_get_buffer(f, buf, 77);
+    qemu_get_8s(f, &s->cmos_index);
+
+    /* Skip loading of s->current_tm, we already have the
+     * information in cmos_data.
+     */
+    qemu_get_buffer(f, buf, 7*4);
+
+    qemu_get_timer(f, s->periodic_timer);
+    s->next_periodic_time = qemu_get_be64(f);
+
+    /* Skip loading of next_second_time, second_timer, second_timer2.  */
+    qemu_get_buffer(f, buf, 3*8);
 
     rtc_set_time(s);
     rtc_set_offset(s, 0);
-    periodic_timer_update(s,  qemu_get_clock_ns(rtc_clock));
     check_update_timer(s);
-
-#ifdef TARGET_I386
-    if (s->lost_tick_policy == LOST_TICK_SLEW) {
-        rtc_coalesced_timer_update(s);
+    if (version_id >= 2) {
+        s->irq_coalesced = qemu_get_be32(f);
+        s->period = qemu_get_be32(f);
     }
-#endif
-    return 0;
+    return rtc_post_load(opaque, version_id);
 }
 
 static const VMStateDescription vmstate_rtc = {
     .name = "mc146818rtc",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 2,
+    .minimum_version_id_old = 1,
     .load_state_old = rtc_load_old,
     .post_load = rtc_post_load,
     .fields      = (VMStateField []) {

Otherwise looks good!

Paolo

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC
  2012-05-09 13:06 ` Paolo Bonzini
@ 2012-05-10  1:41   ` Zhang, Yang Z
  2012-05-10  7:00     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Yang Z @ 2012-05-10  1:41 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: 'aliguori@us.ibm.com', 'qemu-devel@nongnu.org'

> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Wednesday, May 09, 2012 9:07 PM
> Subject: Re: PATCH v5 0/7] RTC: New logic to emulate RTC
> 
> 
> At last this passes my tests, great!  There's still a few problems, but more
> or less it's ok:
> 
> 1) it needs rebase on top of the latest version of QEMU;

I rebased those patches on the top of KVM. I will change to use QEMU in next version.

> 2) it doesn't pass tests/rtc-test, but that might even be a problem with
> the test; I'll try to look at it.

How to use rtc-test? I cannot manage to run rtc-test. I searched in google but get nothing.

> 3) the migration code is not perfect, something like this needs to be
> squashed in
> 
> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
> index e76c34b..026bb29 100644
> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -821,27 +821,34 @@ static int rtc_load_old(QEMUFile *f, void *opaque,
> int version_id)
>      }
> 
>      qemu_get_buffer(f, s->cmos_data, sizeof(s->cmos_data));
> -    /* dummy load for compatibility */
> -    qemu_get_buffer(f, buf, 77);
> +    qemu_get_8s(f, &s->cmos_index);
> +
> +    /* Skip loading of s->current_tm, we already have the
> +     * information in cmos_data.
> +     */
> +    qemu_get_buffer(f, buf, 7*4);
> +
> +    qemu_get_timer(f, s->periodic_timer);
> +    s->next_periodic_time = qemu_get_be64(f);
> +
> +    /* Skip loading of next_second_time, second_timer, second_timer2.  */
> +    qemu_get_buffer(f, buf, 3*8);
> 
>      rtc_set_time(s);
>      rtc_set_offset(s, 0);
> -    periodic_timer_update(s,  qemu_get_clock_ns(rtc_clock));
>      check_update_timer(s);
> -
> -#ifdef TARGET_I386
> -    if (s->lost_tick_policy == LOST_TICK_SLEW) {
> -        rtc_coalesced_timer_update(s);
> +    if (version_id >= 2) {
> +        s->irq_coalesced = qemu_get_be32(f);
> +        s->period = qemu_get_be32(f);
>      }
> -#endif
> -    return 0;
> +    return rtc_post_load(opaque, version_id);
>  }
> 
>  static const VMStateDescription vmstate_rtc = {
>      .name = "mc146818rtc",
>      .version_id = 3,
>      .minimum_version_id = 3,
> -    .minimum_version_id_old = 2,
> +    .minimum_version_id_old = 1,
>      .load_state_old = rtc_load_old,
>      .post_load = rtc_post_load,
>      .fields      = (VMStateField []) {
> 
> Otherwise looks good!

Would you mind if I add your name in Acked-by in next version?

Best regards
yang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC
  2012-05-10  1:41   ` Zhang, Yang Z
@ 2012-05-10  7:00     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2012-05-10  7:00 UTC (permalink / raw)
  To: Zhang, Yang Z
  Cc: 'aliguori@us.ibm.com', 'qemu-devel@nongnu.org'

Il 10/05/2012 03:41, Zhang, Yang Z ha scritto:
>> 2) it doesn't pass tests/rtc-test, but that might even be a problem with
>> the test; I'll try to look at it.
> 
> How to use rtc-test? I cannot manage to run rtc-test. I searched in google but get nothing.

"make check-qtest-i386 V=1" will show how to invoke it with gtester.
You can similarly use gdb instead of gtester.

> Would you mind if I add your name in Acked-by in next version?

I prefer to do some tests myself and reply with Acked-by.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-10  7:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09  7:22 [Qemu-devel] PATCH v5 0/7] RTC: New logic to emulate RTC Zhang, Yang Z
2012-05-09 13:06 ` Paolo Bonzini
2012-05-10  1:41   ` Zhang, Yang Z
2012-05-10  7:00     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).