All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Guthro <bguthro@virtualiron.com>
To: xen-devel <xen-devel@lists.xensource.com>,
	Gary Grebus <ggrebus@virtualiron.com>
Subject: [PATCH] LAPIC timer accounting fix
Date: Wed, 24 Oct 2007 17:12:55 -0400	[thread overview]
Message-ID: <471FB557.9070406@virtualiron.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

Offset emulated local APIC timer so it doesn't tick during guest's
timer related processing. Otherwise, guests using the local APIC for
process accounting can see long sequences of process ticks incorrectly
charged to interrupt processing.

Signed-off-by: Ben Guthro <bguthro@virtualron.com>
Signed-off-by: Gary Grebus <ggrebus@virtualiron.com>

[-- Attachment #2: xen-lapic-timer.patch --]
[-- Type: text/x-patch, Size: 1642 bytes --]

diff -r 68521d709355 xen/arch/x86/hvm/vlapic.c
--- a/xen/arch/x86/hvm/vlapic.c	Tue Sep 11 15:33:54 2007 -0400
+++ b/xen/arch/x86/hvm/vlapic.c	Tue Sep 11 15:33:54 2007 -0400
@@ -962,6 +962,11 @@ void vlapic_destroy(struct vcpu *v)
     free_domheap_page(vlapic->regs_page);
 }
 
+int is_lvtt_vector(struct vcpu *v, int vector)
+{
+    return (vector == vlapic_lvt_vector(vcpu_vlapic(v), APIC_LVTT));
+}
+
 int is_lvtt(struct vcpu *v, int vector)
 {
     return vcpu_vlapic(v)->pt.enabled &&
diff -r 68521d709355 xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c	Tue Sep 11 15:33:54 2007 -0400
+++ b/xen/arch/x86/hvm/vpt.c	Tue Sep 11 15:33:54 2007 -0400
@@ -277,6 +277,13 @@ void create_periodic_time(
     pt->period_cycles = (u64)period * cpu_khz / 1000000L;
     pt->one_shot = one_shot;
     pt->scheduled = NOW() + period;
+    if (is_lvtt_vector(v, irq))
+    {
+        /* Try to offset local APIC ticks from timer ticks.  Otherwise, guests
+           using the local APIC for process accounting can see long sequences
+           of process ticks incorrectly charged to interrupt processing. */
+        pt->scheduled += (period >> 1);
+    }
     pt->cb = cb;
     pt->priv = data;
 
diff -r 68521d709355 xen/include/asm-x86/hvm/vlapic.h
--- a/xen/include/asm-x86/hvm/vlapic.h	Tue Sep 11 15:33:54 2007 -0400
+++ b/xen/include/asm-x86/hvm/vlapic.h	Tue Sep 11 15:33:54 2007 -0400
@@ -92,6 +92,7 @@ struct vlapic *apic_round_robin(
 
 int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda);
 
+int is_lvtt_vector(struct vcpu *v, int vector);
 int is_lvtt(struct vcpu *v, int vector);
 int is_lvtt_enabled(struct vcpu *v);
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2007-10-24 21:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 21:12 Ben Guthro [this message]
2007-10-25 14:16 ` [PATCH] LAPIC timer accounting fix Keir Fraser
2007-10-25 14:50   ` Gary Grebus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=471FB557.9070406@virtualiron.com \
    --to=bguthro@virtualiron.com \
    --cc=ggrebus@virtualiron.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.