Skip to contentSkip to conversation

perfmon2 minimal v2: X86 generic code

PATCH In review [email protected] 2 participants 4 messages Jun 17, 2008 – Jun 27, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 5/19 perfmon2 minimal v2: X86 generic code

This patch adds the X86 generic perfmon2 code. It is in charge of implementing certain key functionalities required by the generic code such as read/write of the PMU registers, low-level interrupt handling.

--

arch/x86/perfmon/Kconfig new file +18 -0
Index: o/arch/x86/perfmon/Kconfig
===================================================================
@@ -0,0 +1,18 @@
+menu "Hardware Performance Monitoring support"
+config PERFMON
+	bool "Perfmon2 performance monitoring interface"
+	select X86_LOCAL_APIC
+	default n
+	help
+	Enables the perfmon2 interface to access the hardware
+	performance counters. See <http://perfmon2.sf.net/> for
+	more details.
+
+config PERFMON_DEBUG
+	bool "Perfmon debugging"
+	default n
+	depends on PERFMON
+	help
+	Enables perfmon debugging support
+
+endmenu
arch/x86/perfmon/Makefile new file +5 -0
Index: o/arch/x86/perfmon/Makefile
===================================================================
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2005-2007 Hewlett-Packard Development Company, L.P.
+# Contributed by Stephane Eranian <[email protected]>
+#
+obj-$(CONFIG_PERFMON)			+= perfmon.o
arch/x86/perfmon/perfmon.c new file +634 -0

634 lines not on this page · raw message

include/asm-x86/perfmon.h new file +34 -0
Index: o/include/asm-x86/perfmon.h
===================================================================
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 Hewlett-Packard Development Company, L.P.
+ * Contributed by Stephane Eranian <[email protected]>
+ *
+ * This file contains i386/x86_64 specific definitions for the perfmon
+ * interface.
+ *
+ * This file MUST never be included directly. Use linux/perfmon.h.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA
+  */
+#ifndef _ASM_X86_PERFMON__H_
+#define _ASM_X86_PERFMON__H_
+
+/*
+ * arch-specific user visible interface definitions
+ */
+
+#define PFM_ARCH_MAX_PMCS	(256+64) /* 256 HW 64 SW */
+#define PFM_ARCH_MAX_PMDS	(256+64) /* 256 HW 64 SW */
+
+#endif /* _ASM_X86_PERFMON_H_ */
include/asm-x86/perfmon_kern.h new file +376 -0

376 lines not on this page · raw message

arch/x86/Kconfig +2 -0
Index: o/arch/x86/Kconfig
===================================================================
@@ -1306,6 +1306,8 @@
 
 	  If unsure, say Y.
 
+source "arch/x86/perfmon/Kconfig"
+
 endmenu
 
 config ARCH_ENABLE_MEMORY_HOTPLUG
arch/x86/Makefile +2 -0
Index: o/arch/x86/Makefile
===================================================================
@@ -176,6 +176,8 @@
 core-y += arch/x86/kernel/
 core-y += arch/x86/mm/
 
+core-$(CONFIG_PERFMON) += arch/x86/perfmon/
+
 # Remaining sub architecture files
 core-y += $(mcore-y)
 
include/asm-x86/Kbuild +1 -0
Index: o/include/asm-x86/Kbuild
===================================================================
@@ -11,6 +11,7 @@
 header-y += sigcontext32.h
 header-y += ucontext.h
 header-y += processor-flags.h
+header-y += perfmon.h
 
 unifdef-y += e820.h
 unifdef-y += ist.h
#1 lore raw

Hi Stephane,

Quoted 5 lines · On Tue, 17 Jun 2008 15:02:22 -0700 (PDT) [email protected] wrote:

This patch adds the X86 generic perfmon2 code. It is in charge of implementing certain key functionalities required by the generic code such as read/write of the PMU registers, low-level interrupt handling.

After applying patches 1-5, building an x86_64 allmodconfig produces these errors:

In file included from include/linux/perfmon_kern.h:167,

                 from arch/x86/perfmon/perfmon.c:25:

include/linux/perfmon_pmu.h:92: warning: ‘struct pfarg_pmc’ declared inside parameter list include/linux/perfmon_pmu.h:92: warning: its scope is only this definition or declaration, which is probably not what you want include/linux/perfmon_pmu.h:96: warning: ‘struct pfarg_pmd’ declared inside parameter list

Those structures aren't defined until patch 11.

In file included from arch/x86/perfmon/perfmon.c:25:
include/linux/perfmon_kern.h: In function ‘pfm_copy_thread’:
include/linux/perfmon_kern.h:199: error: ‘TIF_PERFMON_CTXSW’ undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function ‘smp_pmu_interrupt’:
arch/x86/perfmon/perfmon.c:338: error: ‘LOCAL_PERFMON_VECTOR’ undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function ‘pfm_arch_resend_irq’:
arch/x86/perfmon/perfmon.c:451: error: ‘LOCAL_PERFMON_VECTOR’ undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function ‘pfm_arch_pmu_acquire_percpu’:
arch/x86/perfmon/perfmon.c:475: error: ‘LOCAL_PERFMON_VECTOR’ undeclared (first use in this function)

These are not defined until patch 7.

So I think some rearrangement is still required.

Also, some of the x86 files that you are modifying have had their 32 and 64 bit versions combined in linux-next (which is the stuff of the next merge window) so just a heads up that there will be more merge work then. Lastly, some of this will clash with the generic IPIs work.

I don't want to put you off, you have done great work here, thanks.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#2 lore raw

Stephen,

The patch series is currently structured in such a way that the stack is not build-able at each step.
I should add this to the introduction but you have a first "plateau" at perfmon-syscalls. You cannot
build before that.

As for the linux-next, I do not use it currently, I am still on mainline, maybe that's a mistake.
I will look into this tree.

As for IPI, I hope they have maintained a smp_call_function_single() kind of functionality.

Thanks for your feedback and keep it coming.

Quoted 46 lines · Stephen Rothwell

Hi Stephane,

Quoted 5 lines · On Tue, 17 Jun 2008 15:02:22 -0700 (PDT) [email protected] wrote:

This patch adds the X86 generic perfmon2 code. It is in charge of implementing certain key functionalities required by the generic code such as read/write of the PMU registers, low-level interrupt handling.

After applying patches 1-5, building an x86_64 allmodconfig produces these errors:

In file included from include/linux/perfmon_kern.h:167,

                from arch/x86/perfmon/perfmon.c:25:

include/linux/perfmon_pmu.h:92: warning: 'struct pfarg_pmc' declared inside parameter list include/linux/perfmon_pmu.h:92: warning: its scope is only this definition or declaration, which is probably not what you want include/linux/perfmon_pmu.h:96: warning: 'struct pfarg_pmd' declared inside parameter list

Those structures aren't defined until patch 11.

In file included from arch/x86/perfmon/perfmon.c:25:
include/linux/perfmon_kern.h: In function 'pfm_copy_thread':
include/linux/perfmon_kern.h:199: error: 'TIF_PERFMON_CTXSW' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'smp_pmu_interrupt':
arch/x86/perfmon/perfmon.c:338: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'pfm_arch_resend_irq':
arch/x86/perfmon/perfmon.c:451: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'pfm_arch_pmu_acquire_percpu':
arch/x86/perfmon/perfmon.c:475: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function)

These are not defined until patch 7.

So I think some rearrangement is still required.

Also, some of the x86 files that you are modifying have had their 32 and 64 bit versions combined in linux-next (which is the stuff of the next merge window) so just a heads up that there will be more merge work then. Lastly, some of this will clash with the generic IPIs work.

I don't want to put you off, you have done great work here, thanks.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#3 lore raw
In reply to Stephen Rothwell

Stephen,

Ok, so I cloned your linux-next tree and ported by perfmon2 minimal patch series to it. As you said, there was a handful of files which caused problems, mostly because of x86 merge. But the net effect is that the series is now a bit smaller. I tried some simple perfmon tests and they worked fine. I did not go all the way to the patch which needed IPI (i.e. system-wide support).

However I had problems with this tree and my Broadcom BMC5754 network card. It was not recognized by the tg3 driver so hard to use this kernel.

Quoted 46 lines · Stephen Rothwell

Hi Stephane,

Quoted 5 lines · On Tue, 17 Jun 2008 15:02:22 -0700 (PDT) [email protected] wrote:

This patch adds the X86 generic perfmon2 code. It is in charge of implementing certain key functionalities required by the generic code such as read/write of the PMU registers, low-level interrupt handling.

After applying patches 1-5, building an x86_64 allmodconfig produces these errors:

In file included from include/linux/perfmon_kern.h:167,

                from arch/x86/perfmon/perfmon.c:25:

include/linux/perfmon_pmu.h:92: warning: 'struct pfarg_pmc' declared inside parameter list include/linux/perfmon_pmu.h:92: warning: its scope is only this definition or declaration, which is probably not what you want include/linux/perfmon_pmu.h:96: warning: 'struct pfarg_pmd' declared inside parameter list

Those structures aren't defined until patch 11.

In file included from arch/x86/perfmon/perfmon.c:25:
include/linux/perfmon_kern.h: In function 'pfm_copy_thread':
include/linux/perfmon_kern.h:199: error: 'TIF_PERFMON_CTXSW' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'smp_pmu_interrupt':
arch/x86/perfmon/perfmon.c:338: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'pfm_arch_resend_irq':
arch/x86/perfmon/perfmon.c:451: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function) arch/x86/perfmon/perfmon.c: In function 'pfm_arch_pmu_acquire_percpu':
arch/x86/perfmon/perfmon.c:475: error: 'LOCAL_PERFMON_VECTOR' undeclared (first use in this function)

These are not defined until patch 7.

So I think some rearrangement is still required.

Also, some of the x86 files that you are modifying have had their 32 and 64 bit versions combined in linux-next (which is the stuff of the next merge window) so just a heads up that there will be more merge work then. Lastly, some of this will clash with the generic IPIs work.

I don't want to put you off, you have done great work here, thanks.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/