All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Jacob Pan <jacob.jun.pan@intel.com>,
	Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Yinghai Lu <yinghai@kernel.org>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	avi@redhat.com, gleb@redhat.com
Subject: [PATCH 1/3] apic: add apic_set_eoi_write for PV use
Date: Sun, 15 Jul 2012 15:56:46 +0300	[thread overview]
Message-ID: <db32689adef29a280bc280a6ca88683c44e9d719.1342356186.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1342356186.git.mst@redhat.com>

KVM PV EOI optimization overrides eoi_write apic op with its own
version. Add an API for this to avoid meddling with core x86 apic driver
data structures directly.

For KVM use, we don't need any guarantees about when the switch to the
new op will take place, so it could in theory use this API after SMP init,
but it currently doesn't, and restricting callers to early init makes it
clear that it's safe as it won't race with actual APIC driver use.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/x86/include/asm/apic.h |  3 +++
 arch/x86/kernel/apic/apic.c | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index aa5b2ee..ff8dff6 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -469,6 +469,8 @@ static inline u32 safe_apic_wait_icr_idle(void)
 	return apic->safe_wait_icr_idle();
 }
 
+extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
+
 #else /* CONFIG_X86_LOCAL_APIC */
 
 static inline u32 apic_read(u32 reg) { return 0; }
@@ -478,6 +480,7 @@ static inline u64 apic_icr_read(void) { return 0; }
 static inline void apic_icr_write(u32 low, u32 high) { }
 static inline void apic_wait_icr_idle(void) { }
 static inline u32 safe_apic_wait_icr_idle(void) { return 0; }
+static inline void apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) {}
 
 #endif /* CONFIG_X86_LOCAL_APIC */
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 39a222e..c7520b6 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2124,6 +2124,23 @@ void default_init_apic_ldr(void)
 }
 
 /*
+ * Override the generic EOI implementation with an optimized version.
+ * Only called during early boot when only one CPU is active and with
+ * interrupts disabled, so we know this does not race with actual APIC driver
+ * use.
+ */
+void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v))
+{
+	struct apic **drv;
+
+	for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
+		/* Should happen once for each apic */
+		WARN_ON((*drv)->eoi_write == eoi_write);
+		(*drv)->eoi_write = eoi_write;
+	}
+}
+
+/*
  * Power management
  */
 #ifdef CONFIG_PM
-- 
MST


  reply	other threads:[~2012-07-15 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-15 12:56 [PATCH 0/3] make KVM PV use apic through APIs Michael S. Tsirkin
2012-07-15 12:56 ` Michael S. Tsirkin [this message]
2012-07-16  9:25   ` [PATCH 1/3] apic: add apic_set_eoi_write for PV use Ingo Molnar
2012-07-15 12:56 ` [PATCH 2/3] kvm: switch to apic_set_eoi_write, apic_write Michael S. Tsirkin
2012-07-15 12:56 ` [PATCH 3/3] Revert "apic: fix kvm build on UP without IOAPIC" Michael S. Tsirkin
2012-07-15 13:06 ` [PATCH 0/3] make KVM PV use apic through APIs Avi Kivity
2012-07-16  9:52 ` Avi Kivity

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=db32689adef29a280bc280a6ca88683c44e9d719.1342356186.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=avi@redhat.com \
    --cc=fernando@oss.ntt.co.jp \
    --cc=gleb@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@intel.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /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.