Skip to contentSkip to conversation

x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

PATCH In review Kouya Shimura 4 participants 18 messages Sep 10, 2009 – Sep 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Hi,

I've found that modern windows OS never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

Note: this patch ignores the IRQ mask of legacy i8259 since rombios frequently modifies it.

Thanks,
Kouya

xen/arch/x86/hvm/i8254.c +2 -0
diff -r d2a32e24fe50 xen/arch/x86/hvm/i8254.c
@@ -421,6 +421,8 @@ static int pit_load(struct domain *d, hv
 
     spin_unlock(&pit->lock);
 
+    pt_freeze_pit_timer_if_irqmasked(d);
+
     return 0;
 }
 
xen/arch/x86/hvm/vioapic.c +3 -0
diff -r d2a32e24fe50 xen/arch/x86/hvm/vioapic.c
@@ -158,6 +158,9 @@ static void vioapic_write_redirent(
         pent->fields.remote_irr = 1;
         vioapic_deliver(vioapic, idx);
     }
+
+    if ( idx == hvm_isa_irq_to_gsi(0) && !top_word )
+        pt_freeze_pit_timer_if_irqmasked(d);
 
     spin_unlock(&d->arch.hvm_domain.irq_lock);
 }
xen/arch/x86/hvm/vlapic.c +10 -4
diff -r d2a32e24fe50 xen/arch/x86/hvm/vlapic.c
@@ -655,6 +655,8 @@ static int vlapic_write(struct vcpu *v, 
         vlapic_set_reg(vlapic, offset, val);
         if ( offset == APIC_LVT0 )
             vlapic_adjust_i8259_target(v->domain);
+        if ( offset == APIC_LVTT )
+            pt_freeze_lapic_timer_if_irqmasked(&vlapic->pt);
         break;
 
     case APIC_TMICT:
@@ -770,10 +772,13 @@ void vlapic_adjust_i8259_target(struct d
     v = d->vcpu ? d->vcpu[0] : NULL;
 
  found:
-    if ( d->arch.hvm_domain.i8259_target == v )
-        return;
-    d->arch.hvm_domain.i8259_target = v;
-    pt_adjust_global_vcpu_target(v);
+    if ( d->arch.hvm_domain.i8259_target != v )
+    {
+        d->arch.hvm_domain.i8259_target = v;
+        pt_adjust_global_vcpu_target(v);
+    }
+
+    pt_freeze_pit_timer_if_irqmasked(d);
 }
 
 int vlapic_has_pending_irq(struct vcpu *v)
@@ -934,6 +939,7 @@ static int lapic_load_regs(struct domain
 
     vlapic_adjust_i8259_target(d);
     lapic_rearm(s);
+    pt_freeze_lapic_timer_if_irqmasked(&s->pt);
     return 0;
 }
 
xen/arch/x86/hvm/vpt.c +78 -0

99 lines not on this page · raw message

xen/include/asm-x86/hvm/vpt.h +5 -1
diff -r d2a32e24fe50 xen/include/asm-x86/hvm/vpt.h
@@ -44,6 +44,7 @@ struct periodic_time {
     bool_t do_not_freeze;
     bool_t irq_issued;
     bool_t warned_timeout_too_short;
+    bool_t frozen_by_irqmask;
 #define PTSRC_isa    1 /* ISA time source */
 #define PTSRC_lapic  2 /* LAPIC time source */
     u8 source;                  /* PTSRC_ */
@@ -145,7 +146,10 @@ void pt_adjust_global_vcpu_target(struct
     ((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu ? (d)->vcpu[0] : NULL)
 
 /* Is given periodic timer active? */
-#define pt_active(pt) ((pt)->on_list)
+#define pt_active(pt) ((pt)->on_list || (pt)->frozen_by_irqmask)
+
+void pt_freeze_pit_timer_if_irqmasked(struct domain *d);
+void pt_freeze_lapic_timer_if_irqmasked(struct periodic_time *pt);
 
 /*
  * Create/destroy a periodic (or one-shot!) timer.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Although I can see the sense here, the patch makes me a bit uneasy. Also I think neater code would result from simply making vpt.c's handling of periodic timers less stupid. By this I mean that calling set_timer() from the timer handler is not really necessary -- you already know an interrupt is now pending and the vcpu is kicked. May as well not set_timer() until the pending interrupt(s) are delivered. That would then effectively get your optimisation "for free", wouldn't it?

-- Keir

Quoted 14 lines · Kouya Shimura

Hi,

I've found that modern windows OS never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

Note: this patch ignores the IRQ mask of legacy i8259 since rombios frequently modifies it.

Thanks,
Kouya

#2 lore raw

Well, this patch has two aims. One is to stop the xen's timer by stop_timer(). And another is to simplify pt_update_irq() which searches the earliest platform timer.

To answer the latter aim, this patch gets rid of unused (masked by IRQ) platform timer from vcpu->arch.hvm_vcpu.tm_list. Your suggestion satisfies the first but the latter, I think. Besides, pt_update_irq() is more critical since it is called on every VM_EXIT.

Although I understand your uneasiness, is there any other way?

Thanks,
Kouya

Quoted 27 lines · Keir Fraser

Although I can see the sense here, the patch makes me a bit uneasy. Also I think neater code would result from simply making vpt.c's handling of periodic timers less stupid. By this I mean that calling set_timer() from the timer handler is not really necessary -- you already know an interrupt is now pending and the vcpu is kicked. May as well not set_timer() until the pending interrupt(s) are delivered. That would then effectively get your optimisation "for free", wouldn't it?

-- Keir

Quoted 14 lines · Kouya Shimura

Hi,

I've found that modern windows OS never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

Note: this patch ignores the IRQ mask of legacy i8259 since rombios frequently modifies it.

Thanks,
Kouya

#3 lore raw

Do you get a measurable performance win from this patch?

Not using pt_irq_masked() seems odd. Is it to avoid 859 IRQ mask checks, and if so why are you doing that? Why do we care that rombios twiddles the 8259 masks a bunch during boot?

-- Keir

Quoted 43 lines · Kouya Shimura

Well, this patch has two aims. One is to stop the xen's timer by stop_timer(). And another is to simplify pt_update_irq() which searches the earliest platform timer.

To answer the latter aim, this patch gets rid of unused (masked by IRQ) platform timer from vcpu->arch.hvm_vcpu.tm_list. Your suggestion satisfies the first but the latter, I think. Besides, pt_update_irq() is more critical since it is called on every VM_EXIT.

Although I understand your uneasiness, is there any other way?

Thanks,
Kouya

Quoted 27 lines · Keir Fraser

Although I can see the sense here, the patch makes me a bit uneasy. Also I think neater code would result from simply making vpt.c's handling of periodic timers less stupid. By this I mean that calling set_timer() from the timer handler is not really necessary -- you already know an interrupt is now pending and the vcpu is kicked. May as well not set_timer() until the pending interrupt(s) are delivered. That would then effectively get your optimisation "for free", wouldn't it?

-- Keir

Quoted 14 lines · Kouya Shimura

Hi,

I've found that modern windows OS never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

Note: this patch ignores the IRQ mask of legacy i8259 since rombios frequently modifies it.

Thanks,
Kouya

#4 lore raw
Quoted 1 line · Keir Fraser

Do you get a measurable performance win from this patch?

Sorry, I don't measure yet. Probably a little bit win.

Quoted 3 lines

Not using pt_irq_masked() seems odd. Is it to avoid 859 IRQ mask checks, and if so why are you doing that? Why do we care that rombios twiddles the 8259 masks a bunch during boot?

I guessed that the cost of freezing/thawing a timer with the 8259 mask is higher than timer emulation. And the PIT timer is actually active while rombios masks the 8259.

If using pt_irq_masked() is desirable, I'll remake it.

Thanks,
Kouya

Quoted 49 lines

-- Keir

Quoted 43 lines · Kouya Shimura

Well, this patch has two aims. One is to stop the xen's timer by stop_timer(). And another is to simplify pt_update_irq() which searches the earliest platform timer.

To answer the latter aim, this patch gets rid of unused (masked by IRQ) platform timer from vcpu->arch.hvm_vcpu.tm_list. Your suggestion satisfies the first but the latter, I think. Besides, pt_update_irq() is more critical since it is called on every VM_EXIT.

Although I understand your uneasiness, is there any other way?

Thanks,
Kouya

Quoted 27 lines · Keir Fraser

Although I can see the sense here, the patch makes me a bit uneasy. Also I think neater code would result from simply making vpt.c's handling of periodic timers less stupid. By this I mean that calling set_timer() from the timer handler is not really necessary -- you already know an interrupt is now pending and the vcpu is kicked. May as well not set_timer() until the pending interrupt(s) are delivered. That would then effectively get your optimisation "for free", wouldn't it?

-- Keir

Quoted 14 lines · Kouya Shimura

Hi,

I've found that modern windows OS never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

Note: this patch ignores the IRQ mask of legacy i8259 since rombios frequently modifies it.

Thanks,
Kouya

#5 lore raw
Quoted 9 lines · Kouya Shimura
Quoted 3 lines

Not using pt_irq_masked() seems odd. Is it to avoid 859 IRQ mask checks, and if so why are you doing that? Why do we care that rombios twiddles the 8259 masks a bunch during boot?

I guessed that the cost of freezing/thawing a timer with the 8259 mask is higher than timer emulation. And the PIT timer is actually active while rombios masks the 8259.

If using pt_irq_masked() is desirable, I'll remake it.

If your patch works without even any theoretical lost of correctness, then that makes it more attractive, obviously.

Some evidence that the cost saving is at all measurable would also be good. Premature optimisation being evil, etc. ;-)

-- Keir

#6 lore raw

I remade the patch and measured the performance win. Attached is a benchmark program which I wrote. It is complied by cygwin's gcc by -O2 and runs on Windows XP(32bit). And my cpu is Intel Core2 Quad [email protected].

The result is that my patch saves 32 cycles(TSC) per one VM_EXIT(cpuid). (2696 tsc => 2664 tsc)

The patch is split to two. I'll post them in another mail.

Thanks,
Kouya

Quoted 12 lines · Keir Fraser
Quoted 9 lines · Kouya Shimura
Quoted 3 lines

Not using pt_irq_masked() seems odd. Is it to avoid 859 IRQ mask checks, and if so why are you doing that? Why do we care that rombios twiddles the 8259 masks a bunch during boot?

I guessed that the cost of freezing/thawing a timer with the 8259 mask is higher than timer emulation. And the PIT timer is actually active while rombios masks the 8259.

If using pt_irq_masked() is desirable, I'll remake it.

Quoted 7 lines

If your patch works without even any theoretical lost of correctness, then that makes it more attractive, obviously.

Some evidence that the cost saving is at all measurable would also be good. Premature optimisation being evil, etc. ;-)

-- Keir

#include <stdio.h>
#include <stdint.h>

#define rdtsc(val) asm volatile("rdtsc" : "=a" (val))

static void cpuid(uint32_t idx)

{
    uint32_t a,b,c,d;
    asm volatile("cpuid": "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(idx) );
}

main()

{
    uint32_t tsc1, tsc2;
    while(1) {
	rdtsc(tsc1);
	cpuid(0x40000000);
	rdtsc(tsc2);
	printf("tsc=%d\n", tsc2 - tsc1);
    }
}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw

PATCH 1/2 x86 hvm: don't set periodical timer again until its IRQ is delivered.

Modern Windows OS (ex XP,2003,2008) never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

With this patch, setting a timer is defered while its IRQ is masked.

The reasons why pt_timer_fn() simply calls vcpu_kick() are:
- checking by pt_irq_masked() is duplicated. pt_update_irq() also does.
- pt_timer_fn() is likely called on the same processor
as pt->vcpu->processor. Hence vcpu_kick() hardly send IPI.

# HG changeset patch
# User Kouya Shimura <[email protected]>
# Date 1253081156 -32400
# Node ID 864f20763d03ef989501fbc43d74034027679a56
# Parent d2a32e24fe504b9626e6732b4f213c7cb1bc8b57
x86 hvm: don't set periodical timer again until its IRQ is delivered.

Modern Windows OS (ex XP,2003,2008) never use the PIT timer, and neither cpu#0's LAPIC timer after boot. Despite that, xen emulates them busily. It's inefficient.

With this patch, setting a timer is defered while its IRQ is masked.

The reasons why pt_timer_fn() simply calls vcpu_kick() are:
- checking by pt_irq_masked() is duplicated. pt_update_irq() also does.
- pt_timer_fn() is likely called on the same processor
as pt->vcpu->processor. Hence vcpu_kick() hardly send IPI.

xen/arch/x86/hvm/vpt.c +12 -11
diff -r d2a32e24fe50 -r 864f20763d03 xen/arch/x86/hvm/vpt.c
@@ -187,8 +187,11 @@ void pt_restore_timer(struct vcpu *v)
 
     list_for_each_entry ( pt, head, list )
     {
-        pt_process_missed_ticks(pt);
-        set_timer(&pt->timer, pt->scheduled);
+        if ( pt->pending_intr_nr == 0 )
+        {
+            pt_process_missed_ticks(pt);
+            set_timer(&pt->timer, pt->scheduled);
+        }
     }
 
     pt_thaw_time(v);
@@ -205,15 +208,7 @@ static void pt_timer_fn(void *data)
     pt->pending_intr_nr++;
     pt->do_not_freeze = 0;
 
-    if ( !pt->one_shot )
-    {
-        pt->scheduled += pt->period;
-        pt_process_missed_ticks(pt);
-        set_timer(&pt->timer, pt->scheduled);
-    }
-
-    if ( !pt_irq_masked(pt) )
-        vcpu_kick(pt->vcpu);
+    vcpu_kick(pt->vcpu);
 
     pt_unlock(pt);
 }
@@ -302,6 +297,9 @@ void pt_intr_post(struct vcpu *v, struct
     }
     else
     {
+        pt->scheduled += pt->period;
+        pt_process_missed_ticks(pt);
+
         if ( mode_is(v->domain, one_missed_tick_pending) ||
              mode_is(v->domain, no_missed_ticks_pending) )
         {
@@ -313,6 +311,9 @@ void pt_intr_post(struct vcpu *v, struct
             pt->last_plt_gtime += pt->period;
             pt->pending_intr_nr--;
         }
+
+        if ( pt->pending_intr_nr == 0 )
+            set_timer(&pt->timer, pt->scheduled);
     }
 
     if ( mode_is(v->domain, delay_for_missed_ticks) &&

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#8 lore raw

PATCH 2/2 x86 hvm: suspend platform timer emulation while its IRQ is masked

This patch gets rid of a timer which IRQ is masked from vcpu's timer list. It reduces the overhead of VM EXIT and context switch of vm.

Also fixes a potential bug.
(1) VCPU#0: mask the IRQ of a timer. (ex. vioapic.redir[2].mask=1)
(2) VCPU#1: pt_timer_fn() is invoked by expiration of the timer.
(3) VCPU#1: pt_update_irq() is called but does nothing by pt_irq_masked()=1.
(4) VCPU#1: sleep by halt.
(5) VCPU#0: unmask the IRQ of the timer.
After that, no one wakes up the VCPU#1.

IRQ of ISA is masked by:
- PIC's IMR
- IOAPIC's redir[0]
- IOAPIC's redir[N].mask
- LAPIC's LVT0
- LAPIC enabled/disabled

IRQ of LAPIC timer is masked by:
- LAPIC's LVTT
- LAPIC disabled

When above stuffs are changed, the corresponding vcpu is kicked and suspended timer emulation is resumed.

In addition, a small bug fix in pt_adjust_global_vcpu_target().

# HG changeset patch
# User Kouya Shimura <[email protected]>
# Date 1253080328 -32400
# Node ID b62a5e4c6125e62fd5fd1e28f7ae1c8a093b689d
# Parent 58ef1439ca982cdd2f7e4698ce9bdba1f4b38853
x86 hvm: suspend platform timer emulation while its IRQ is masked

This patch gets rid of a timer which IRQ is masked from vcpu's timer list. It reduces the overhead of VM EXIT and context switch of vm.

Also fixes a potential bug.
(1) VCPU#0: mask the IRQ of a timer. (ex. vioapic.redir[2].mask=1)
(2) VCPU#1: pt_timer_fn() is invoked by expiration of the timer.
(3) VCPU#1: pt_update_irq() is called but does nothing by pt_irq_masked()=1.
(4) VCPU#1: sleep by halt.
(5) VCPU#0: unmask the IRQ of the timer.
After that, no one wakes up the VCPU#1.

IRQ of ISA is masked by:
- PIC's IMR
- IOAPIC's redir[0]
- IOAPIC's redir[N].mask
- LAPIC's LVT0
- LAPIC enabled/disabled

IRQ of LAPIC timer is masked by:
- LAPIC's LVTT
- LAPIC disabled

When above stuffs are changed, the corresponding vcpu is kicked and suspended timer emulation is resumed.

In addition, a small bug fix in pt_adjust_global_vcpu_target().

xen/arch/x86/hvm/vioapic.c +6 -0
diff -r 58ef1439ca98 -r b62a5e4c6125 xen/arch/x86/hvm/vioapic.c
@@ -125,6 +125,7 @@ static void vioapic_write_redirent(
     struct domain *d = vioapic_domain(vioapic);
     struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
     union vioapic_redir_entry *pent, ent;
+    int unmasked = 0;
 
     spin_lock(&d->arch.hvm_domain.irq_lock);
 
@@ -138,10 +139,12 @@ static void vioapic_write_redirent(
     }
     else
     {
+        unmasked = ent.fields.mask;
         /* Remote IRR and Delivery Status are read-only. */
         ent.bits = ((ent.bits >> 32) << 32) | val;
         ent.fields.delivery_status = 0;
         ent.fields.remote_irr = pent->fields.remote_irr;
+        unmasked = unmasked && !ent.fields.mask;
     }
 
     *pent = ent;
@@ -160,6 +163,9 @@ static void vioapic_write_redirent(
     }
 
     spin_unlock(&d->arch.hvm_domain.irq_lock);
+
+    if ( idx == 0 || unmasked )
+        pt_may_unmask_irq(d, NULL);
 }
 
 static void vioapic_write_indirect(
xen/arch/x86/hvm/vlapic.c +10 -0
diff -r 58ef1439ca98 -r b62a5e4c6125 xen/arch/x86/hvm/vlapic.c
@@ -624,7 +624,10 @@ static int vlapic_write(struct vcpu *v, 
             }
         }
         else
+        {
             vlapic->hw.disabled &= ~VLAPIC_SW_DISABLED;
+            pt_may_unmask_irq(vlapic_domain(vlapic), &vlapic->pt);
+        }
         break;
 
     case APIC_ESR:
@@ -654,7 +657,12 @@ static int vlapic_write(struct vcpu *v, 
         val &= vlapic_lvt_mask[(offset - APIC_LVTT) >> 4];
         vlapic_set_reg(vlapic, offset, val);
         if ( offset == APIC_LVT0 )
+        {
             vlapic_adjust_i8259_target(v->domain);
+            pt_may_unmask_irq(v->domain, NULL);
+        }
+        if ( (offset == APIC_LVTT) && !(val & APIC_LVT_MASKED) )
+            pt_may_unmask_irq(NULL, &vlapic->pt);
         break;
 
     case APIC_TMICT:
@@ -719,10 +727,12 @@ void vlapic_msr_set(struct vlapic *vlapi
         {
             vlapic_reset(vlapic);
             vlapic->hw.disabled &= ~VLAPIC_HW_DISABLED;
+            pt_may_unmask_irq(vlapic_domain(vlapic), &vlapic->pt);
         }
         else
         {
             vlapic->hw.disabled |= VLAPIC_HW_DISABLED;
+            pt_may_unmask_irq(vlapic_domain(vlapic), NULL);
         }
     }
 
xen/arch/x86/hvm/vpic.c +6 -1
diff -r 58ef1439ca98 -r b62a5e4c6125 xen/arch/x86/hvm/vpic.c
@@ -178,7 +178,7 @@ static void vpic_ioport_write(
     struct hvm_hw_vpic *vpic, uint32_t addr, uint32_t val)
 {
     int priority, cmd, irq;
-    uint8_t mask;
+    uint8_t mask, unmasked = 0;
 
     vpic_lock(vpic);
 
@@ -190,6 +190,7 @@ static void vpic_ioport_write(
             /* Clear edge-sensing logic. */
             vpic->irr &= vpic->elcr;
 
+            unmasked = vpic->imr;
             /* No interrupts masked or in service. */
             vpic->imr = vpic->isr = 0;
 
@@ -268,6 +269,7 @@ static void vpic_ioport_write(
         {
         case 0:
             /* OCW1 */
+            unmasked = vpic->imr & (~val);
             vpic->imr = val;
             break;
         case 1:
@@ -295,6 +297,9 @@ static void vpic_ioport_write(
     vpic_update_int_output(vpic);
 
     vpic_unlock(vpic);
+
+    if ( unmasked )
+        pt_may_unmask_irq(vpic_domain(vpic), NULL);
 }
 
 static uint32_t vpic_ioport_read(struct hvm_hw_vpic *vpic, uint32_t addr)
xen/arch/x86/hvm/vpt.c +53 -7

92 lines not on this page · raw message

xen/include/asm-x86/hvm/vpt.h +3 -1
diff -r 58ef1439ca98 -r b62a5e4c6125 xen/include/asm-x86/hvm/vpt.h
@@ -144,8 +144,10 @@ void pt_adjust_global_vcpu_target(struct
 #define pt_global_vcpu_target(d) \
     ((d)->arch.hvm_domain.i8259_target ? : (d)->vcpu ? (d)->vcpu[0] : NULL)
 
+void pt_may_unmask_irq(struct domain *d, struct periodic_time *vlapic_pt);
+
 /* Is given periodic timer active? */
-#define pt_active(pt) ((pt)->on_list)
+#define pt_active(pt) ((pt)->on_list || (pt)->pending_intr_nr)
 
 /*
  * Create/destroy a periodic (or one-shot!) timer.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw
In reply to Kouya Shimura
Quoted 9 lines · Kouya Shimura

I remade the patch and measured the performance win. Attached is a benchmark program which I wrote. It is complied by cygwin's gcc by -O2 and runs on Windows XP(32bit). And my cpu is Intel Core2 Quad [email protected].

The result is that my patch saves 32 cycles(TSC) per one VM_EXIT(cpuid). (2696 tsc => 2664 tsc)

The patch is split to two. I'll post them in another mail.

That's really not enough of a win to bother with, is it.

-- Keir

#10 lore raw

Looks the little win doesn't deserve the increased complexity in code.

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

Thanks,
-- Dexuan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: 2009?9?16? 15:41
To: Kouya Shimura
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Quoted 9 lines · Kouya Shimura

I remade the patch and measured the performance win. Attached is a benchmark program which I wrote. It is complied by cygwin's gcc by -O2 and runs on Windows XP(32bit). And my cpu is Intel Core2 Quad [email protected].

The result is that my patch saves 32 cycles(TSC) per one VM_EXIT(cpuid). (2696 tsc => 2664 tsc)

The patch is split to two. I'll post them in another mail.

That's really not enough of a win to bother with, is it.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#11 lore raw
Quoted 4 lines · Dexuan

Looks the little win doesn't deserve the increased complexity in code.

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

Makes it more appealing doesn't it? As this path will be a greater proportion of an overall vmexit/vmenter cycle.

-- Keir

#12 lore raw

I'm not sure if the number of the saved cycles is the same on recent Intel CPUs, so the proportion may not be greater. :-)

Thanks,
-- Dexuan

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 2009?9?16? 16:21
To: Cui, Dexuan; Kouya Shimura
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Quoted 4 lines · Dexuan

Looks the little win doesn't deserve the increased complexity in code.

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

Makes it more appealing doesn't it? As this path will be a greater proportion of an overall vmexit/vmenter cycle.

-- Keir

#13 lore raw

Perhaps. Anyway, the patches fixed bugs and generally cleaned up some logic, so I think they are good for reasons other than the few saved cycles on vmenter.

-- Keir

Quoted 25 lines · Dexuan

I'm not sure if the number of the saved cycles is the same on recent Intel CPUs, so the proportion may not be greater. :-)

Thanks,
-- Dexuan

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 2009?9?16? 16:21
To: Cui, Dexuan; Kouya Shimura
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Quoted 4 lines · Dexuan

Looks the little win doesn't deserve the increased complexity in code.

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

Makes it more appealing doesn't it? As this path will be a greater proportion of an overall vmexit/vmenter cycle.

-- Keir

#14 lore raw
In reply to Cui, Dexuan
Quoted 1 line · Dexuan

Looks the little win doesn't deserve the increased complexity in code.

Agreed. I don't strongly push my patches.
But this win is given by 2/2 patch and it fixes a certain bug. Besides, 1/2 patch simplifies the code, I think.

Quoted 1 line

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

I have a "Mottainai"(http://en.wikipedia.org/wiki/Mottainai) spirit. :-)

Thanks,
Kouya

Quoted 35 lines

Thanks,
-- Dexuan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: 2009?9?16? 15:41
To: Kouya Shimura
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Quoted 9 lines · Kouya Shimura

I remade the patch and measured the performance win. Attached is a benchmark program which I wrote. It is complied by cygwin's gcc by -O2 and runs on Windows XP(32bit). And my cpu is Intel Core2 Quad [email protected].

The result is that my patch saves 32 cycles(TSC) per one VM_EXIT(cpuid). (2696 tsc => 2664 tsc)

The patch is split to two. I'll post them in another mail.

That's really not enough of a win to bother with, is it.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#15 lore raw

I liked both patches when I looked at them, so I checked them in and we'll see how well they work!

-- Keir

Quoted 52 lines · Kouya Shimura
Quoted 1 line · Dexuan

Looks the little win doesn't deserve the increased complexity in code.

Agreed. I don't strongly push my patches.
But this win is given by 2/2 patch and it fixes a certain bug. Besides, 1/2 patch simplifies the code, I think.

Quoted 2 lines

BTW, recent Intel CPUs run much faster with respect to VMEntry/VMExit and VMREAD/VMWRITE, so I don't think the SW optimizatin is appearling here. :-)

I have a "Mottainai"(http://en.wikipedia.org/wiki/Mottainai) spirit. :-)

Thanks,
Kouya

Quoted 37 lines

Thanks,
-- Dexuan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: 2009?9?16? 15:41
To: Kouya Shimura
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] x86 hvm: freeze PIT/LAPIC timer emulation while its IRQ is masked

Quoted 9 lines · Kouya Shimura

I remade the patch and measured the performance win. Attached is a benchmark program which I wrote. It is complied by cygwin's gcc by -O2 and runs on Windows XP(32bit). And my cpu is Intel Core2 Quad [email protected].

The result is that my patch saves 32 cycles(TSC) per one VM_EXIT(cpuid). (2696 tsc => 2664 tsc)

The patch is split to two. I'll post them in another mail.

That's really not enough of a win to bother with, is it.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#16 lore raw
In reply to Kouya Shimura

On Thu, Sep 10, 2009 at 02:47:22PM +0900, Kouya Shimura wrote:
Content-Description: message body text

Quoted 3 lines

Hi,

I've found that modern windows OS never use the PIT timer,

What about older Linux versions? Like RHEL3?

#17 lore raw
Quoted 7 lines · Konrad Rzeszutek Wilk

On Thu, Sep 10, 2009 at 02:47:22PM +0900, Kouya Shimura wrote:
Content-Description: message body text

Quoted 3 lines

Hi,

I've found that modern windows OS never use the PIT timer,

What about older Linux versions? Like RHEL3?

older Linux uses the PIT timer. Although I don't know about RHEL3, RHEL5 uses the PIT timer actually.

Any way, my patch doesn't give a benefit to Linux. For example, linux-2.6.28 (ubuntu 9.04) stops the PIT timer by itself.

Thanks,
Kouya