Skip to contentSkip to conversation

perfcounters updates

GIT PULL Ingo Molnar 1 participant 1 message Jun 20, 2009

Subsystems (7)
x86 VFS PowerPC perf events +3 more subsystems
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest perfcounters git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git perfcounters-fixes-for-linus

This is a bit large and fresh - but i hope this is still acceptable in the merge window.

The main focus of the changes is the fixing of call-chain profiling and its push through the 'perf' tool and finalization of the call-chain ABI, and the fixing of a couple of bugs this exposed. (On x86 we went for the safer solution of using fast-gup for the call-chains - this is slower but only affects perfcounters. The faster and nicer solution of removing nested IRETs and save/restore-ing cr2 is being worked on.)

The other bigger change is PowerPC-32 support from Paulus. BenH has acked these changes, and has acked this (one-off) route towards mainline as well.

Note: there's a new default a_ops helper added to fs/anon_inodes.c, Al Viro was Cc:-ed to that patch (no reply yet). Apparently perfcounters is the first anon-fd user to allow writable mmaps.

Thanks,

Ingo

------------------>
Frederic Weisbecker (4):
perf annotate: Print the filename:line for annotated colored lines perf annotate: Print a sorted summary of annotated overhead lines perf annotate: Fixes for filename:line displays
perfcounter: Handle some IO return values

Ingo Molnar (14):
perf stat: Reorganize output
perf stat: Add feature to run and measure a command multiple times perf stat: Enable raw data to be printed
perf report: Print out raw events in hexa
perf record/report: Add call graph / call chain profiling perf_counter, x86: Fix call-chain walking
perf_counter, x86: Fix kernel-space call-chains
perf record: Fix fast task-exit race
perf report: Add per system call overhead histogram
perf report: Fix 32-bit printf format
perf report: Tidy up the "--parent <regex>" and "--sort parent" call-chain features perf report: Add validation of call-chain entries
perf report: Filter to parent set by default
perf_counter, x86: Improve interactions with fast-gup

Jaswinder Singh Rajput (2):
perf_counter, x86: Check old-AMD performance monitoring support perf_counter, x86: Update AMD hw caching related event table

Marti Raudsepp (1):
perf_counter: Fix stack corruption in perf_read_hw

Paul Mackerras (10):
perf_counter: Fix atomic_set vs. atomic64_t type mismatch
perf_counter: powerpc: Fix two compile warnings
perf_counter: Make set_perf_counter_pending() declaration common
perf_counter: powerpc: Enable use of software counters on 32-bit powerpc
perf_counter: powerpc: Use unsigned long for register and constraint values
perf_counter: powerpc: Change how processor-specific back-ends get selected
perf_counter: powerpc: Make powerpc perf_counter code safe for 32-bit kernels
perf_counter: powerpc: Add processor back-end for MPC7450 family
perf_counter: tools: Makefile tweaks for 64-bit powerpc perf_counter tools: Define and use our own u64, s64 etc. definitions

Peter Zijlstra (18):
perf_counter: Fix ctx->mutex vs counter->mutex inversion x86, mm: Add __get_user_pages_fast()
x86: Add NMI types for kmap_atomic
perf_counter: x86: Fix call-chain support to use NMI-safe methods
x86: Add NMI types for kmap_atomic, fix
perf report: Add --sort <call> --call <$regex>
perf_counter: x86: Set the period in the intel overflow handler perf_counter tools: Replace isprint() with issane() perf_counter tools: Add and use isprint()
fs: Provide empty .set_page_dirty() aop for anon inodes
perf_counter: Add event overlow handling
perf_counter tools: Handle lost events
perf_counter: Make callchain samples extensible
perf_counter: Update userspace callchain sampling uses perf_counter tools: Add a data file header
perf_counter: Simplify and fix task migration counting
perf_counter: Close race in perf_lock_task_context()
perf_counter: Push perf_sample_data through the swcounter code

 arch/powerpc/Kconfig                    |    1 +
 arch/powerpc/include/asm/hw_irq.h       |    6 +-
 arch/powerpc/include/asm/perf_counter.h |   52 +++--
 arch/powerpc/kernel/Makefile            |    8 +-
 arch/powerpc/kernel/mpc7450-pmu.c       |  417 +++++++++++++++++++++++++++++
 arch/powerpc/kernel/perf_counter.c      |  257 +++++++++++--------
 arch/powerpc/kernel/power4-pmu.c        |   89 ++++---
 arch/powerpc/kernel/power5+-pmu.c       |   95 ++++---
 arch/powerpc/kernel/power5-pmu.c        |   98 ++++---
 arch/powerpc/kernel/power6-pmu.c        |   72 +++--
 arch/powerpc/kernel/power7-pmu.c        |   61 +++--
 arch/powerpc/kernel/ppc970-pmu.c        |   63 +++--
 arch/powerpc/kernel/time.c              |   25 ++
 arch/powerpc/platforms/Kconfig.cputype  |   12 +-
 arch/x86/include/asm/perf_counter.h     |    5 -
 arch/x86/include/asm/pgtable_32.h       |    8 +-
 arch/x86/include/asm/uaccess.h          |    7 +-
 arch/x86/kernel/cpu/perf_counter.c      |  138 ++++++-----
 arch/x86/mm/gup.c                       |   58 ++++-
 fs/anon_inodes.c                        |   15 +
 include/asm-generic/kmap_types.h        |    5 +-
 include/linux/mm.h                      |    6 +
 include/linux/perf_counter.h            |   79 ++++--
 kernel/perf_counter.c                   |  312 +++++++++++++----------
 kernel/sched.c                          |    3 +-
 tools/perf/Makefile                     |   10 +-
 tools/perf/builtin-annotate.c           |  262 +++++++++++++++----
 tools/perf/builtin-record.c             |  163 +++++++-----
 tools/perf/builtin-report.c             |  439 +++++++++++++++++++++++++------
 tools/perf/builtin-stat.c               |  308 ++++++++++++++++------
 tools/perf/builtin-top.c                |   24 +-
 tools/perf/perf.h                       |    7 +
 tools/perf/types.h                      |   17 ++
 tools/perf/util/ctype.c                 |   17 +-
 tools/perf/util/parse-events.c          |   14 +-
 tools/perf/util/string.c                |    2 +-
 tools/perf/util/string.h                |    4 +-
 tools/perf/util/symbol.c                |   20 +-
 tools/perf/util/symbol.h                |   16 +-
 tools/perf/util/util.h                  |   18 +-
 40 files changed, 2321 insertions(+), 892 deletions(-)
 create mode 100644 arch/powerpc/kernel/mpc7450-pmu.c
 create mode 100644 tools/perf/types.h
arch/powerpc/Kconfig +1 -0
index 9fb344d..bf6cedf 100644
@@ -126,6 +126,7 @@ config PPC
 	select HAVE_OPROFILE
 	select HAVE_SYSCALL_WRAPPERS if PPC64
 	select GENERIC_ATOMIC64 if PPC32
+	select HAVE_PERF_COUNTERS
 
 config EARLY_PRINTK
 	bool
arch/powerpc/include/asm/hw_irq.h +4 -2
index b7f8f4a..867ab8e 100644
@@ -131,6 +131,8 @@ static inline int irqs_disabled_flags(unsigned long flags)
 struct irq_chip;
 
 #ifdef CONFIG_PERF_COUNTERS
+
+#ifdef CONFIG_PPC64
 static inline unsigned long test_perf_counter_pending(void)
 {
 	unsigned long x;
@@ -154,15 +156,15 @@ static inline void clear_perf_counter_pending(void)
 		"r" (0),
 		"i" (offsetof(struct paca_struct, perf_counter_pending)));
 }
+#endif /* CONFIG_PPC64 */
 
-#else
+#else  /* CONFIG_PERF_COUNTERS */
 
 static inline unsigned long test_perf_counter_pending(void)
 {
 	return 0;
 }
 
-static inline void set_perf_counter_pending(void) {}
 static inline void clear_perf_counter_pending(void) {}
 #endif /* CONFIG_PERF_COUNTERS */
 
arch/powerpc/include/asm/perf_counter.h +31 -21

79 lines not on this page · raw message

arch/powerpc/kernel/Makefile +5 -3
index 612b0c4..a9f8829 100644
@@ -95,9 +95,10 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
 
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
-obj-$(CONFIG_PERF_COUNTERS)	+= perf_counter.o power4-pmu.o ppc970-pmu.o \
-				   power5-pmu.o power5+-pmu.o power6-pmu.o \
-				   power7-pmu.o
+obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_counter.o
+obj64-$(CONFIG_PPC_PERF_CTRS)	+= power4-pmu.o ppc970-pmu.o power5-pmu.o \
+				   power5+-pmu.o power6-pmu.o power7-pmu.o
+obj32-$(CONFIG_PPC_PERF_CTRS)	+= mpc7450-pmu.o
 
 obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o
 
@@ -106,6 +107,7 @@ obj-y				+= iomap.o
 endif
 
 obj-$(CONFIG_PPC64)		+= $(obj64-y)
+obj-$(CONFIG_PPC32)		+= $(obj32-y)
 
 ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),)
 obj-y				+= ppc_save_regs.o
arch/powerpc/kernel/mpc7450-pmu.c new file +417 -0

417 lines not on this page · raw message

arch/powerpc/kernel/perf_counter.c +150 -107

404 lines not on this page · raw message

arch/powerpc/kernel/power4-pmu.c +53 -36

154 lines not on this page · raw message

arch/powerpc/kernel/power5+-pmu.c +56 -39

173 lines not on this page · raw message

arch/powerpc/kernel/power5-pmu.c +57 -41

185 lines not on this page · raw message

arch/powerpc/kernel/power6-pmu.c +43 -29

136 lines not on this page · raw message

arch/powerpc/kernel/power7-pmu.c +39 -22

103 lines not on this page · raw message

arch/powerpc/kernel/ppc970-pmu.c +40 -23

131 lines not on this page · raw message

arch/powerpc/kernel/time.c +25 -0
index 15391c2..eae4511 100644
@@ -53,6 +53,7 @@
 #include <linux/posix-timers.h>
 #include <linux/irq.h>
 #include <linux/delay.h>
+#include <linux/perf_counter.h>
 
 #include <asm/io.h>
 #include <asm/processor.h>
@@ -525,6 +526,26 @@ void __init iSeries_time_init_early(void)
 }
 #endif /* CONFIG_PPC_ISERIES */
 
+#if defined(CONFIG_PERF_COUNTERS) && defined(CONFIG_PPC32)
+DEFINE_PER_CPU(u8, perf_counter_pending);
+
+void set_perf_counter_pending(void)
+{
+	get_cpu_var(perf_counter_pending) = 1;
+	set_dec(1);
+	put_cpu_var(perf_counter_pending);
+}
+
+#define test_perf_counter_pending()	__get_cpu_var(perf_counter_pending)
+#define clear_perf_counter_pending()	__get_cpu_var(perf_counter_pending) = 0
+
+#else  /* CONFIG_PERF_COUNTERS && CONFIG_PPC32 */
+
+#define test_perf_counter_pending()	0
+#define clear_perf_counter_pending()
+
+#endif /* CONFIG_PERF_COUNTERS && CONFIG_PPC32 */
+
 /*
  * For iSeries shared processors, we have to let the hypervisor
  * set the hardware decrementer.  We set a virtual decrementer
@@ -551,6 +572,10 @@ void timer_interrupt(struct pt_regs * regs)
 	set_dec(DECREMENTER_MAX);
 
 #ifdef CONFIG_PPC32
+	if (test_perf_counter_pending()) {
+		clear_perf_counter_pending();
+		perf_counter_do_pending();
+	}
 	if (atomic_read(&ppc_n_lost_interrupts) != 0)
 		do_IRQ(regs);
 #endif
arch/powerpc/platforms/Kconfig.cputype +11 -1
index cca6b4f..8485c8c 100644
@@ -1,7 +1,7 @@
 config PPC64
 	bool "64-bit kernel"
 	default n
-	select HAVE_PERF_COUNTERS
+	select PPC_HAVE_PMU_SUPPORT
 	help
 	  This option selects whether a 32-bit or a 64-bit kernel
 	  will be built.
@@ -75,6 +75,7 @@ config POWER4_ONLY
 config 6xx
 	def_bool y
 	depends on PPC32 && PPC_BOOK3S
+	select PPC_HAVE_PMU_SUPPORT
 
 config POWER3
 	bool
@@ -243,6 +244,15 @@ config VIRT_CPU_ACCOUNTING
 
 	  If in doubt, say Y here.
 
+config PPC_HAVE_PMU_SUPPORT
+       bool
+
+config PPC_PERF_CTRS
+       def_bool y
+       depends on PERF_COUNTERS && PPC_HAVE_PMU_SUPPORT
+       help
+         This enables the powerpc-specific perf_counter back-end.
+
 config SMP
 	depends on PPC_STD_MMU || FSL_BOOKE
 	bool "Symmetric multi-processing support"
arch/x86/include/asm/perf_counter.h +0 -5
index 876ed97..5fb33e1 100644
@@ -84,11 +84,6 @@ union cpuid10_edx {
 #define MSR_ARCH_PERFMON_FIXED_CTR2			0x30b
 #define X86_PMC_IDX_FIXED_BUS_CYCLES			(X86_PMC_IDX_FIXED + 2)
 
-extern void set_perf_counter_pending(void);
-
-#define clear_perf_counter_pending()	do { } while (0)
-#define test_perf_counter_pending()	(0)
-
 #ifdef CONFIG_PERF_COUNTERS
 extern void init_hw_perf_counters(void);
 extern void perf_counters_lapic_init(void);
arch/x86/include/asm/pgtable_32.h +6 -2
index 31bd120..01fd946 100644
@@ -49,13 +49,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
 #endif
 
 #if defined(CONFIG_HIGHPTE)
+#define __KM_PTE			\
+	(in_nmi() ? KM_NMI_PTE : 	\
+	 in_irq() ? KM_IRQ_PTE :	\
+	 KM_PTE0)
 #define pte_offset_map(dir, address)					\
-	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
+	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), __KM_PTE) +		\
 	 pte_index((address)))
 #define pte_offset_map_nested(dir, address)				\
 	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) +		\
 	 pte_index((address)))
-#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
+#define pte_unmap(pte) kunmap_atomic((pte), __KM_PTE)
 #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
 #else
 #define pte_offset_map(dir, address)					\
arch/x86/include/asm/uaccess.h +6 -1
index b685ece..512ee87 100644
@@ -25,7 +25,12 @@
 #define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
 
 #define KERNEL_DS	MAKE_MM_SEG(-1UL)
-#define USER_DS		MAKE_MM_SEG(PAGE_OFFSET)
+
+#ifdef CONFIG_X86_32
+# define USER_DS	MAKE_MM_SEG(PAGE_OFFSET)
+#else
+# define USER_DS	MAKE_MM_SEG(__VIRTUAL_MASK)
+#endif
 
 #define get_ds()	(KERNEL_DS)
 #define get_fs()	(current_thread_info()->addr_limit)
arch/x86/kernel/cpu/perf_counter.c +74 -64

253 lines not on this page · raw message

arch/x86/mm/gup.c +57 -1

70 lines not on this page · raw message

fs/anon_inodes.c +15 -0
index 1dd96d4..47d4a01 100644
@@ -52,6 +52,19 @@ static const struct dentry_operations anon_inodefs_dentry_operations = {
 	.d_delete	= anon_inodefs_delete_dentry,
 };
 
+/*
+ * nop .set_page_dirty method so that people can use .page_mkwrite on
+ * anon inodes.
+ */
+static int anon_set_page_dirty(struct page *page)
+{
+	return 0;
+};
+
+static const struct address_space_operations anon_aops = {
+	.set_page_dirty = anon_set_page_dirty,
+};
+
 /**
  * anon_inode_getfd - creates a new file instance by hooking it up to an
  *                    anonymous inode, and a dentry that describe the "class"
@@ -151,6 +164,8 @@ static struct inode *anon_inode_mkinode(void)
 
 	inode->i_fop = &anon_inode_fops;
 
+	inode->i_mapping->a_ops = &anon_aops;
+
 	/*
 	 * Mark the inode dirty from the very beginning,
 	 * that way it will never be moved to the dirty
include/asm-generic/kmap_types.h +4 -1
index 54e8b3d..eddbce0 100644
@@ -24,7 +24,10 @@ D(12)	KM_SOFTIRQ1,
 D(13)	KM_SYNC_ICACHE,
 D(14)	KM_SYNC_DCACHE,
 D(15)	KM_UML_USERCOPY, /* UML specific, for copy_*_user - used in do_op_one_page */
-D(16)	KM_TYPE_NR
+D(16)	KM_IRQ_PTE,
+D(17)	KM_NMI,
+D(18)	KM_NMI_PTE,
+D(19)	KM_TYPE_NR
 };
 
 #undef D
include/linux/mm.h +6 -0
index d88d6fc..cf260d8 100644
@@ -854,6 +854,12 @@ extern int mprotect_fixup(struct vm_area_struct *vma,
 			  unsigned long end, unsigned long newflags);
 
 /*
+ * doesn't attempt to fault and will return short.
+ */
+int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
+			  struct page **pages);
+
+/*
  * A callback you can register to apply pressure to ageable caches.
  *
  * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'.  It should
include/linux/perf_counter.h +49 -30

147 lines not on this page · raw message

kernel/perf_counter.c +178 -134

530 lines not on this page · raw message

kernel/sched.c +2 -1
index 8fb88a9..f46540b 100644

Lines of this file are not shown. View the raw message.

tools/perf/Makefile +8 -2
index 0cbd5d6..36d7eef 100644

Lines of this file are not shown. View the raw message.

tools/perf/builtin-annotate.c +214 -48

262 lines not on this page · raw message

tools/perf/builtin-record.c +103 -60

163 lines not on this page · raw message

tools/perf/builtin-report.c +352 -87

439 lines not on this page · raw message

tools/perf/builtin-stat.c +231 -77

308 lines not on this page · raw message

tools/perf/builtin-top.c +12 -12
index fe338d3..5352b5e 100644

Lines of this file are not shown. View the raw message.

tools/perf/perf.h +7 -0
index 87a1aca..bccb529 100644

Lines of this file are not shown. View the raw message.

tools/perf/types.h new file +17 -0
new file mode 100644
index 0000000..5e75f90

Lines of this file are not shown. View the raw message.

tools/perf/util/ctype.c +11 -6
index b90ec00..0b791bd 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/parse-events.c +7 -7
index 5a72586..35d04da 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/string.c +1 -1
index ec33c0c..c93eca9 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/string.h +2 -2
index 72812c1..37b0325 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/symbol.c +10 -10
index 49a55f8..86e1437 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/symbol.h +9 -7
index 0d1292b..ea332e5 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/util.h +8 -10
index 76590a1..b8cfed7 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.