ppc32: oprofile support
PATCH 1/1 ppc32: oprofile support
Hi !
This patch adds basic oprofile support to ppc32. Originally from Anton Blanchard, I just re-diffed it against current kernels. Please apply,
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Signed-off-by Anton Blanchard <[email protected]>
arch/ppc/Kconfig +1 -0
@@ -1183,6 +1183,7 @@ source "lib/Kconfig" +source "arch/ppc/oprofile/Kconfig" menu "Kernel hacking"
arch/ppc/Makefile +2 -0
@@ -50,6 +50,8 @@ drivers-$(CONFIG_4xx) += arch/ppc/4xx_io/ drivers-$(CONFIG_8260) += arch/ppc/8260_io/ +drivers-$(CONFIG_OPROFILE) += arch/ppc/oprofile/ + BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm .PHONY: $(BOOT_TARGETS)
arch/ppc/kernel/time.c +15 -7
@@ -56,6 +56,7 @@#include <linux/mc146818rtc.h> #include <linux/time.h> #include <linux/init.h> +#include <linux/profile.h> #include <asm/segment.h> #include <asm/io.h>
@@ -107,17 +108,23 @@return delta; } -extern unsigned long prof_cpu_mask; -extern unsigned int * prof_buffer; -extern unsigned long prof_len; -extern unsigned long prof_shift;extern char _stext; -static inline void ppc_do_profile (unsigned long nip) +static inline void ppc_do_profile (struct pt_regs *regs) { +unsigned long nip; +extern unsigned long prof_cpu_mask; + +profile_hook (regs); + +if (user_mode (regs)) +return ; +if (!prof_buffer)return ; + nip =instruction_pointer (regs); +/* * Only measure the CPUs specified by /proc/irq/prof_cpu_mask. * (default is all CPUs.)
@@ -156,8 +163,9 @@while ((next_dec = tb_ticks_per_jiffy -tb_delta (&jiffy_stamp)) <0 ) { jiffy_stamp += tb_ticks_per_jiffy; -if (!user_mode (regs)) -ppc_do_profile (instruction_pointer (regs)); + +ppc_do_profile (regs); +if (smp_processor_id ())continue ;
arch/ppc/oprofile/Kconfig new file +23 -0
@@ -0,0 +1,23 @@ + +menu "Profiling support" + depends on EXPERIMENTAL + +config PROFILING + bool "Profiling support (EXPERIMENTAL)" + help + Say Y here to enable the extended profiling support mechanisms used + by profilers such as OProfile. + + +config OPROFILE + tristate "OProfile system profiling (EXPERIMENTAL)" + depends on PROFILING + help + OProfile is a profiling system capable of profiling the + whole system, include the kernel, kernel modules, libraries, + and applications. + + If unsure, say N. + +endmenu +
arch/ppc/oprofile/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +obj-$(CONFIG_OPROFILE) += oprofile.o + +DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \ + oprof.o cpu_buffer.o buffer_sync.o \ + event_buffer.o oprofile_files.o \ + oprofilefs.o oprofile_stats.o \ + timer_int.o ) + +oprofile-y := $(DRIVER_OBJS) init.o
arch/ppc/oprofile/init.c new file +23 -0
@@ -0,0 +1,23 @@ +/** +* @file init.c +* +* @remark Copyright 2002 OProfile authors +* @remark Read the file COPYING +* +* @author John Levon <[email protected]> +*/ + +#include <linux/kernel.h> +#include <linux/oprofile.h> +#include <linux/init.h> +#include <linux/errno.h> + +int __init oprofile_arch_init (struct oprofile_operations ** ops) +{ +return -ENODEV ; +} + + +void oprofile_arch_exit (void ) +{ +}