patch for ia64 oprofile support for 2.5.67 kernel
I started with the most recent 2.5 kernel for ia64 I could find, the stock 2.5.67 kernel from kernel.org with the linuxia64.org patch (linux-2.5.67-ia64-030416.diff.bz2). Attached is a patch that provides oprofile kernel support that works oprofile 0.5.2. It is built on top of the perfmon support. For the oprofile to use the performance monitoring hardware CONFIG_PERFMON also needs to be enabled in .config. If perfmon support is not enabled, oprofile will just supply the basic TIMER_INT implementation.
The patch applies cleanly to the 2.5.67 kernel with the linuxia64.org patchs. I have built the kernel, with required code compiled in (no modules) and booted the resulting kernel successfully on an Intanium 2 SMP machine. I am sure some revison is required for the patch for the 2.5.69 kernel. There was some refactoring of the code TIMER_INT code.
Comments?
-Will
arch/ia64/kernel/time.c renamed from arch/ia64/kernel/time.c.orig +3 -31
@@ -17,6 +17,7 @@#include <linux/time.h> #include <linux/interrupt.h> #include <linux/efi.h> +#include <linux/profile.h> #include <asm/delay.h> #include <asm/hw_irq.h>
@@ -35,30 +36,6 @@#endif -static void -do_profile (unsigned long ip) -{ -extern unsigned long prof_cpu_mask; -extern char _stext; - -if (!prof_buffer) -return ; - -if (!((1UL <<smp_processor_id ()) & prof_cpu_mask)) -return ; - - ip -= (unsigned long ) &_stext; - ip >>= prof_shift; -/* -* Don't ignore out-of-bounds IP values silently, put them into the last -* histogram slot, so if present, they will show up as a sharp peak. -*/ -if (ip > prof_len -1 ) - ip = prof_len -1 ; - -atomic_inc ((atomic_t *) &prof_buffer[ip]); -} -/* * Return the number of nano-seconds that elapsed since the last update to jiffy. The * xtime_lock must be at least read-locked when calling this routine.
@@ -186,14 +163,9 @@printk (KERN_ERR "Oops: timer tick before it's due (itc=%lx,itm=%lx)\n" ,ia64_get_itc (), new_itm); +ia64_do_profile (regs); +while (1 ) { -/* -* Do kernel PC profiling here. We multiply the instruction number by -* four so that we can use a prof_shift of 2 to get instruction-level -* instead of just bundle-level accuracy. -*/ -if (!user_mode (regs)) -do_profile (regs->cr_iip +4 *ia64_psr (regs)->ri);#ifdef CONFIG_SMP smp_do_timer (regs);
arch/ia64/kernel/perfmon.c renamed from arch/ia64/kernel/perfmon.c.orig +0 -3
@@ -132,9 +132,6 @@#define PFM_REG_RETFLAG_SET (flags, val) do { flags &= ~PFM_REG_RETFL_MASK; flags |= (val); } while(0) -#define PFM_CPUINFO_CLEAR (v) __get_cpu_var(pfm_syst_info) &= ~(v) -#define PFM_CPUINFO_SET (v) __get_cpu_var(pfm_syst_info) |= (v) -/* * debugging */
arch/ia64/Makefile renamed from arch/ia64/Makefile.orig +2 -0
@@ -56,6 +56,8 @@ drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/ drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ +# must be linked after kernel/ +drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/ boot := arch/ia64/boot tools := arch/ia64/tools
arch/ia64/oprofile/Kconfig renamed from arch/ia64/oprofile/Kconfig.orig +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/ia64/oprofile/init.c renamed from arch/ia64/oprofile/init.c.orig +29 -0
@@ -0,0 +1,29 @@ +/** +* @file init.c +* +* @remark Copyright 2002-2003 OProfile authors +* @remark Read the file COPYING +* +* @author John Levon <[email protected]> +* @author Will Cohen <[email protected]> +*/ + +#include <linux/kernel.h> +#include <linux/oprofile.h> +#include <linux/init.h> + +/* We support CPUs that have performance counters like the IA64 +* with irq mode samples. +*/ + +extern int irq_init (struct oprofile_operations ** ops); +extern void timer_init (struct oprofile_operations ** ops); + +int __init oprofile_arch_init (struct oprofile_operations ** ops) +{ +#ifdef CONFIG_PERFMON + if (!irq_init(ops)) +#endif +timer_init (ops); +return 0 ; +}
arch/ia64/oprofile/irq_int.c renamed from arch/ia64/oprofile/irq_int.c.orig +253 -0
253 lines not on this page · raw message
arch/ia64/oprofile/Makefile renamed from arch/ia64/oprofile/Makefile.orig +11 -0
@@ -0,0 +1,11 @@ +# arch/ia64/oprofile/Makefile + +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 ) + +oprofile-y := $(DRIVER_OBJS) init.o timer_int.o +oprofile-$(CONFIG_PERFMON) += irq_int.o op_model_ia64.o
arch/ia64/oprofile/op_counter.h renamed from arch/ia64/oprofile/op_counter.h.orig +29 -0
@@ -0,0 +1,29 @@ +/** +* @file op_counter.h +* +* @remark Copyright 2002 OProfile authors +* @remark Read the file COPYING +* +* @author John Levon +*/ + +#ifndef OP_COUNTER_H +#define OP_COUNTER_H + +#define OP_MAX_COUNTER 8 + +/* Per-perfctr configuration as set via +* oprofilefs. +*/ +struct op_counter_config { +unsigned long count; +unsigned long enabled; +unsigned long event; +unsigned long kernel; +unsigned long user; +unsigned long unit_mask; +}; + +extern struct op_counter_config counter_config[]; + +#endif /* OP_COUNTER_H */
arch/ia64/oprofile/op_ia64_model.h renamed from arch/ia64/oprofile/op_ia64_model.h.orig +80 -0
80 lines not on this page · raw message
arch/ia64/oprofile/op_model_ia64.c renamed from arch/ia64/oprofile/op_model_ia64.c.orig +210 -0
210 lines not on this page · raw message
arch/ia64/oprofile/timer_int.c renamed from arch/ia64/oprofile/timer_int.c.orig +57 -0
57 lines not on this page · raw message
arch/ia64/Kconfig renamed from arch/ia64/Kconfig.orig +1 -0
@@ -782,6 +782,7 @@ source "arch/ia64/hp/sim/Kconfig" +source "arch/ia64/oprofile/Kconfig" menu "Kernel hacking"
include/asm-ia64/hw_irq.h renamed from include/asm-ia64/hw_irq.h.orig +43 -0
53 lines not on this page · raw message
include/asm-ia64/perfmon.h renamed from include/asm-ia64/perfmon.h.orig +3 -0
@@ -199,6 +199,9 @@#define PFM_CPUINFO_EXCL_IDLE 0x4/* the system wide session excludes the idle task */ +#define PFM_CPUINFO_CLEAR (v) __get_cpu_var(pfm_syst_info) &= ~(v) +#define PFM_CPUINFO_SET (v) __get_cpu_var(pfm_syst_info) |= (v) +#endif /* __KERNEL__ */ #endif /* _ASM_IA64_PERFMON_H */
include/asm-ia64/ptrace.h renamed from include/asm-ia64/ptrace.h.orig +1 -0
@@ -214,6 +214,7 @@ };#ifdef __KERNEL__ +#define instruction_pointer (regs) ((regs)->cr_iip)/* given a pointer to a task_struct, return the user's pt_regs */ # define ia64_task_regs (t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)# define ia64_psr (regs) ((struct ia64_psr *) &(regs)->cr_ipsr)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Will Cohen
Bill> Comments?
The patch looks fine for 2.4 purposes, but for 2.5/2.6, I'd much prefer to see all PMU-related manipulation done in user-space (through the perfmon syscall and/or pfmlib). I really don't want to have to maintain _two_ subsystems that need to be updated with each new processor.
I talked to Stephane about this and he said he should have the "custom sampling buffer format" patch ready in about a week's time. Once that is in, you should be able to hook oprofile to perfmon with a trivial glue "module".
--david
How are things going on the "custom sampling buffer format" patch? Is there somthing availble I can look at this time?
-Will
Quoted 17 lines · David Mosberger
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · Will Cohen
Bill> Comments?
The patch looks fine for 2.4 purposes, but for 2.5/2.6, I'd much prefer to see all PMU-related manipulation done in user-space (through the perfmon syscall and/or pfmlib). I really don't want to have to maintain _two_ subsystems that need to be updated with each new processor.
I talked to Stephane about this and he said he should have the "custom sampling buffer format" patch ready in about a week's time. Once that is in, you should be able to hook oprofile to perfmon with a trivial glue "module".
--david
Will,
Quoted 3 lines · Will Cohen
How are things going on the "custom sampling buffer format" patch? Is there somthing availble I can look at this time?
It is in fairly good shape for 2.5.69. I hope to get this to David for the next kernel patch (2.5.70 or higher).
Can you wait that long?
Signature · 1 line
-Stephane