Skip to contentSkip to conversation

rtc/mc146818rtc: improve rtc performance

PATCH New Evanzhang 2 participants 3 messages Jul 24, 2023 – Sep 25, 2023

lore
Share & tools
lore

Evanzhang

author
#0 lore raw

PATCH 1/1 rtc/mc146818rtc: improve rtc performance

1.hw/rtc/mc146818rtc.c:48
open #define DEBUG_COALESCEDOD
2.create win7 4u 4g vm
3.Play 1080p video full screen
4.observe qemu log message
DPRINTF_C("cmos: coalesced irqs decreased to %d\n", s->irq_coalesced);
4.perf kvm stat record -a -p $(pidof qemu-kvm) sleep 600
perf kvm stat report --event=vmexit
5.record EXTERNAL_INTERRUPT

Evanzhang (1):
rtc/mc146818rtc: improve rtc performance

 hw/rtc/mc146818rtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH 1/1 rtc/mc146818rtc: improve rtc performance

under heavy workloads,irq_coalesced could up to 30+, after modification EXTERNAL_INTERRUPT reduce by 40%

before:
Analyze events for all VMs, all VCPUs:

             VM-EXIT    Samples  Samples%     Time%

       EPT_VIOLATION    9833984    63.41%    15.96%
      IO_INSTRUCTION    2160843    13.93%    50.07%
  EXTERNAL_INTERRUPT    1949267    12.57%     0.89%
          APIC_WRITE     767795     4.95%     0.55%
         EOI_INDUCED     615308     3.97%     0.30%
                 HLT     130821     0.84%    31.77%

after:
Analyze events for all VMs, all VCPUs:

             VM-EXIT    Samples  Samples%     Time%

       EPT_VIOLATION    5238031    50.91%     6.44%
      IO_INSTRUCTION    2257658    21.94%    54.88%
  EXTERNAL_INTERRUPT    1160086    11.28%     0.61%
          APIC_WRITE     780454     7.59%     0.54%
         EOI_INDUCED     615309     5.98%     0.28%
                 HLT     179703     1.75%    36.87%
---
 hw/rtc/mc146818rtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/rtc/mc146818rtc.c +2 -2
index c27c362..2995078 100644
@@ -96,8 +96,8 @@ static void rtc_coalesced_timer_update(MC146818RtcState *s)
     if (s->irq_coalesced == 0) {
         timer_del(s->coalesced_timer);
     } else {
-        /* divide each RTC interval to 2 - 8 smaller intervals */
-        int c = MIN(s->irq_coalesced, 7) + 1;
+        /* divide each RTC interval to 2 - 32 smaller intervals */
+        int c = MIN(s->irq_coalesced, 31) + 1;
         int64_t next_clock = qemu_clock_get_ns(rtc_clock) +
             periodic_clock_to_ns(s->period / c);
         timer_mod(s->coalesced_timer, next_clock);
Signature · 1 line
2.9.5
Reviewed-by on v1 1/1
#2 lore raw
Quoted 25 lines · Evanzhang

under heavy workloads,irq_coalesced could up to 30+, after modification EXTERNAL_INTERRUPT reduce by 40%

before:
Analyze events for all VMs, all VCPUs:

             VM-EXIT    Samples  Samples%     Time%

       EPT_VIOLATION    9833984    63.41%    15.96%
      IO_INSTRUCTION    2160843    13.93%    50.07%
  EXTERNAL_INTERRUPT    1949267    12.57%     0.89%
          APIC_WRITE     767795     4.95%     0.55%
         EOI_INDUCED     615308     3.97%     0.30%
                 HLT     130821     0.84%    31.77%

after:
Analyze events for all VMs, all VCPUs:

             VM-EXIT    Samples  Samples%     Time%

       EPT_VIOLATION    5238031    50.91%     6.44%
      IO_INSTRUCTION    2257658    21.94%    54.88%
  EXTERNAL_INTERRUPT    1160086    11.28%     0.61%
          APIC_WRITE     780454     7.59%     0.54%
         EOI_INDUCED     615309     5.98%     0.28%
                 HLT     179703     1.75%    36.87%
Quoted 1 line

Paolo do you mind picking this old patch up?

Quoted 21 lines
---
 hw/rtc/mc146818rtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/rtc/mc146818rtc.c +2 -2
index c27c362..2995078 100644
@@ -96,8 +96,8 @@ static void rtc_coalesced_timer_update(MC146818RtcState *s)
     if (s->irq_coalesced == 0) {
         timer_del(s->coalesced_timer);
     } else {
-        /* divide each RTC interval to 2 - 8 smaller intervals */
-        int c = MIN(s->irq_coalesced, 7) + 1;
+        /* divide each RTC interval to 2 - 32 smaller intervals */
+        int c = MIN(s->irq_coalesced, 31) + 1;
         int64_t next_clock = qemu_clock_get_ns(rtc_clock) +
             periodic_clock_to_ns(s->period / c);
         timer_mod(s->coalesced_timer, next_clock);
Signature · 1 line
2.9.5