All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] x86, apic, perf - make apic_write/read noop on !APIC case
@ 2010-03-17 10:36 Cyrill Gorcunov
  2010-03-17 10:37 ` [patch 1/2] x86, apic: Allow to use sertain functions without APIC built-in support Cyrill Gorcunov
  2010-03-17 10:37 ` [patch 2/2] x86, perf: Use apic_write unconditionally Cyrill Gorcunov
  0 siblings, 2 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2010-03-17 10:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: x86

This allow us to save some #ifdef's.
Please review.

Cyrill

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

* [patch 1/2] x86, apic: Allow to use sertain functions without APIC built-in support
  2010-03-17 10:36 [patch 0/2] x86, apic, perf - make apic_write/read noop on !APIC case Cyrill Gorcunov
@ 2010-03-17 10:37 ` Cyrill Gorcunov
  2010-03-18 17:37   ` [tip:perf/core] x86, apic: Allow to use certain " tip-bot for Cyrill Gorcunov
  2010-03-17 10:37 ` [patch 2/2] x86, perf: Use apic_write unconditionally Cyrill Gorcunov
  1 sibling, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2010-03-17 10:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, H. Peter Anvin, Ingo Molnar, Thomas Gleixner, Yinghai Lu,
	Cyrill Gorcunov

[-- Attachment #1: x86-apic-write-relax --]
[-- Type: text/plain, Size: 1947 bytes --]

In case even if the kernel is configured so that
no APIC support is built-in we still may allow
to use sertain apic functions as a dummy calls.

In particular we start using it in perf-events code.

Note that this is not that same as NOOP apic driver,
the reverse -- we don't have apic code compiled at all.

CC: H. Peter Anvin <hpa@zytor.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 arch/x86/include/asm/apic.h |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Index: linux-2.6.git/arch/x86/include/asm/apic.h
=====================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/apic.h
+++ linux-2.6.git/arch/x86/include/asm/apic.h
@@ -373,6 +373,7 @@ extern atomic_t init_deasserted;
 extern int wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip);
 #endif
 
+#ifdef CONFIG_X86_LOCAL_APIC
 static inline u32 apic_read(u32 reg)
 {
 	return apic->read(reg);
@@ -403,10 +404,19 @@ static inline u32 safe_apic_wait_icr_idl
 	return apic->safe_wait_icr_idle();
 }
 
+#else /* CONFIG_X86_LOCAL_APIC */
+
+static inline u32 apic_read(u32 reg) { return 0; }
+static inline void apic_write(u32 reg, u32 val) { }
+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; }
+
+#endif /* CONFIG_X86_LOCAL_APIC */
 
 static inline void ack_APIC_irq(void)
 {
-#ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * ack_APIC_irq() actually gets compiled as a single instruction
 	 * ... yummie.
@@ -414,7 +424,6 @@ static inline void ack_APIC_irq(void)
 
 	/* Docs say use 0 for future compatibility */
 	apic_write(APIC_EOI, 0);
-#endif
 }
 
 static inline unsigned default_get_apic_id(unsigned long x)


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

* [patch 2/2] x86, perf: Use apic_write unconditionally
  2010-03-17 10:36 [patch 0/2] x86, apic, perf - make apic_write/read noop on !APIC case Cyrill Gorcunov
  2010-03-17 10:37 ` [patch 1/2] x86, apic: Allow to use sertain functions without APIC built-in support Cyrill Gorcunov
@ 2010-03-17 10:37 ` Cyrill Gorcunov
  2010-03-18 17:37   ` [tip:perf/core] " tip-bot for Cyrill Gorcunov
  1 sibling, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2010-03-17 10:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: x86, fweisbec, acme, eranian, peterz, Cyrill Gorcunov

[-- Attachment #1: x86-perf-use-apic-dummy --]
[-- Type: text/plain, Size: 1823 bytes --]

Since apic_write maps to a plain noop in !CONFIG_X86_LOCAL_APIC
case we're safe to remove this conditional compilation
and clean code a bit.

CC: fweisbec@gmail.com
CC: acme@redhat.com
CC: eranian@google.com
CC: peterz@infradead.org
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 arch/x86/kernel/cpu/perf_event.c    |    4 ----
 arch/x86/kernel/cpu/perf_event_p4.c |    2 --
 2 files changed, 6 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/cpu/perf_event.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/cpu/perf_event.c
+++ linux-2.6.git/arch/x86/kernel/cpu/perf_event.c
@@ -1135,7 +1135,6 @@ void set_perf_event_pending(void)
 
 void perf_events_lapic_init(void)
 {
-#ifdef CONFIG_X86_LOCAL_APIC
 	if (!x86_pmu.apic || !x86_pmu_initialized())
 		return;
 
@@ -1143,7 +1142,6 @@ void perf_events_lapic_init(void)
 	 * Always use NMI for PMU
 	 */
 	apic_write(APIC_LVTPC, APIC_DM_NMI);
-#endif
 }
 
 static int __kprobes
@@ -1167,9 +1165,7 @@ perf_event_nmi_handler(struct notifier_b
 
 	regs = args->regs;
 
-#ifdef CONFIG_X86_LOCAL_APIC
 	apic_write(APIC_LVTPC, APIC_DM_NMI);
-#endif
 	/*
 	 * Can't rely on the handled return value to say it was our NMI, two
 	 * events could trigger 'simultaneously' raising two back-to-back NMIs.
Index: linux-2.6.git/arch/x86/kernel/cpu/perf_event_p4.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/cpu/perf_event_p4.c
+++ linux-2.6.git/arch/x86/kernel/cpu/perf_event_p4.c
@@ -363,10 +363,8 @@ static int p4_pmu_handle_irq(struct pt_r
 	}
 
 	if (handled) {
-#ifdef CONFIG_X86_LOCAL_APIC
 		/* p4 quirk: unmask it again */
 		apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED);
-#endif
 		inc_irq_stat(apic_perf_irqs);
 	}
 


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

* [tip:perf/core] x86, apic: Allow to use certain functions without APIC built-in support
  2010-03-17 10:37 ` [patch 1/2] x86, apic: Allow to use sertain functions without APIC built-in support Cyrill Gorcunov
@ 2010-03-18 17:37   ` tip-bot for Cyrill Gorcunov
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Cyrill Gorcunov @ 2010-03-18 17:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, yinghai, gorcunov, tglx, mingo

Commit-ID:  d674cd1963129b70bc5f631c51fb30fb73213fb2
Gitweb:     http://git.kernel.org/tip/d674cd1963129b70bc5f631c51fb30fb73213fb2
Author:     Cyrill Gorcunov <gorcunov@openvz.org>
AuthorDate: Wed, 17 Mar 2010 13:37:00 +0300
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 18 Mar 2010 17:03:21 +0100

x86, apic: Allow to use certain functions without APIC built-in support

In case even if the kernel is configured so that
no APIC support is built-in we still may allow
to use certain apic functions as dummy calls.

In particular we start using it in perf-events code.

Note that this is not that same as NOOP apic driver (which
is used if APIC support is present but no physical APIC is
available), this is for the case when we don't have apic code
compiled in at all.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <20100317104356.011052632@openvz.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/include/asm/apic.h |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index b4ac2cd..1fa03e0 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -373,6 +373,7 @@ extern atomic_t init_deasserted;
 extern int wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip);
 #endif
 
+#ifdef CONFIG_X86_LOCAL_APIC
 static inline u32 apic_read(u32 reg)
 {
 	return apic->read(reg);
@@ -403,10 +404,19 @@ static inline u32 safe_apic_wait_icr_idle(void)
 	return apic->safe_wait_icr_idle();
 }
 
+#else /* CONFIG_X86_LOCAL_APIC */
+
+static inline u32 apic_read(u32 reg) { return 0; }
+static inline void apic_write(u32 reg, u32 val) { }
+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; }
+
+#endif /* CONFIG_X86_LOCAL_APIC */
 
 static inline void ack_APIC_irq(void)
 {
-#ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * ack_APIC_irq() actually gets compiled as a single instruction
 	 * ... yummie.
@@ -414,7 +424,6 @@ static inline void ack_APIC_irq(void)
 
 	/* Docs say use 0 for future compatibility */
 	apic_write(APIC_EOI, 0);
-#endif
 }
 
 static inline unsigned default_get_apic_id(unsigned long x)

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

* [tip:perf/core] x86, perf: Use apic_write unconditionally
  2010-03-17 10:37 ` [patch 2/2] x86, perf: Use apic_write unconditionally Cyrill Gorcunov
@ 2010-03-18 17:37   ` tip-bot for Cyrill Gorcunov
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Cyrill Gorcunov @ 2010-03-18 17:37 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, gorcunov, tglx, mingo

Commit-ID:  7335f75e9ca166044e38a96abad422d8e6e364b5
Gitweb:     http://git.kernel.org/tip/7335f75e9ca166044e38a96abad422d8e6e364b5
Author:     Cyrill Gorcunov <gorcunov@openvz.org>
AuthorDate: Wed, 17 Mar 2010 13:37:01 +0300
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 18 Mar 2010 17:03:22 +0100

x86, perf: Use apic_write unconditionally

Since apic_write() maps to a plain noop in the !CONFIG_X86_LOCAL_APIC
case we're safe to remove this conditional compilation and clean up
the code a bit.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: fweisbec@gmail.com
Cc: acme@redhat.com
Cc: eranian@google.com
Cc: peterz@infradead.org
LKML-Reference: <20100317104356.232371479@openvz.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/cpu/perf_event.c    |    4 ----
 arch/x86/kernel/cpu/perf_event_p4.c |    2 --
 2 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index c97d5b5..14eca80 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1136,7 +1136,6 @@ void set_perf_event_pending(void)
 
 void perf_events_lapic_init(void)
 {
-#ifdef CONFIG_X86_LOCAL_APIC
 	if (!x86_pmu.apic || !x86_pmu_initialized())
 		return;
 
@@ -1144,7 +1143,6 @@ void perf_events_lapic_init(void)
 	 * Always use NMI for PMU
 	 */
 	apic_write(APIC_LVTPC, APIC_DM_NMI);
-#endif
 }
 
 static int __kprobes
@@ -1168,9 +1166,7 @@ perf_event_nmi_handler(struct notifier_block *self,
 
 	regs = args->regs;
 
-#ifdef CONFIG_X86_LOCAL_APIC
 	apic_write(APIC_LVTPC, APIC_DM_NMI);
-#endif
 	/*
 	 * Can't rely on the handled return value to say it was our NMI, two
 	 * events could trigger 'simultaneously' raising two back-to-back NMIs.
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index a11ce73..0367889 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -363,10 +363,8 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
 	}
 
 	if (handled) {
-#ifdef CONFIG_X86_LOCAL_APIC
 		/* p4 quirk: unmask it again */
 		apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED);
-#endif
 		inc_irq_stat(apic_perf_irqs);
 	}
 

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

end of thread, other threads:[~2010-03-18 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-17 10:36 [patch 0/2] x86, apic, perf - make apic_write/read noop on !APIC case Cyrill Gorcunov
2010-03-17 10:37 ` [patch 1/2] x86, apic: Allow to use sertain functions without APIC built-in support Cyrill Gorcunov
2010-03-18 17:37   ` [tip:perf/core] x86, apic: Allow to use certain " tip-bot for Cyrill Gorcunov
2010-03-17 10:37 ` [patch 2/2] x86, perf: Use apic_write unconditionally Cyrill Gorcunov
2010-03-18 17:37   ` [tip:perf/core] " tip-bot for Cyrill Gorcunov

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.