Commit 18f2190d authored by Maynard Johnson's avatar Maynard Johnson Committed by Paul Mackerras

[POWERPC] cell: Add oprofile support

Add PPU event-based and cycle-based profiling support to Oprofile for Cell.

Oprofile is expected to collect data on all CPUs simultaneously.
However, there is one set of performance counters per node.  There are
two hardware threads or virtual CPUs on each node.  Hence, OProfile must
multiplex in time the performance counter collection on the two virtual
CPUs.

The multiplexing of the performance counters is done by a virtual
counter routine.  Initially, the counters are configured to collect data
on the even CPUs in the system, one CPU per node.  In order to capture
the PC for the virtual CPU when the performance counter interrupt occurs
(the specified number of events between samples has occurred), the even
processors are configured to handle the performance counter interrupts
for their node.  The virtual counter routine is called via a kernel
timer after the virtual sample time.  The routine stops the counters,
saves the current counts, loads the last counts for the other virtual
CPU on the node, sets interrupts to be handled by the other virtual CPU
and restarts the counters, the virtual timer routine is scheduled to run
again.  The virtual sample time is kept relatively small to make sure
sampling occurs on both CPUs on the node with a relatively small
granularity.  Whenever the counters overflow, the performance counter
interrupt is called to collect the PC for the CPU where data is being
collected.

The oprofile driver relies on a firmware RTAS call to setup the debug bus
to route the desired signals to the performance counter hardware to be
counted.  The RTAS call must set the routing registers appropriately in
each of the islands to pass the signals down the debug bus as well as
routing the signals from a particular island onto the bus.  There is a
second firmware RTAS call to reset the debug bus to the non pass thru
state when the counters are not in use.
Signed-off-by: default avatarCarl Love <carll@us.ibm.com>
Signed-off-by: default avatarMaynard Johnson <mpjohn@us.ibm.com>
Signed-off-by: default avatarArnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 0443bbd3
...@@ -1121,7 +1121,8 @@ CONFIG_PLIST=y ...@@ -1121,7 +1121,8 @@ CONFIG_PLIST=y
# #
# Instrumentation Support # Instrumentation Support
# #
# CONFIG_PROFILING is not set CONFIG_PROFILING=y
CONFIG_OPROFILE=y
# CONFIG_KPROBES is not set # CONFIG_KPROBES is not set
# #
......
...@@ -304,6 +304,9 @@ static struct cpu_spec cpu_specs[] = { ...@@ -304,6 +304,9 @@ static struct cpu_spec cpu_specs[] = {
PPC_FEATURE_SMT, PPC_FEATURE_SMT,
.icache_bsize = 128, .icache_bsize = 128,
.dcache_bsize = 128, .dcache_bsize = 128,
.num_pmcs = 4,
.oprofile_cpu_type = "ppc64/cell-be",
.oprofile_type = PPC_OPROFILE_CELL,
.platform = "ppc-cell-be", .platform = "ppc-cell-be",
}, },
{ /* PA Semi PA6T */ { /* PA Semi PA6T */
......
...@@ -11,6 +11,7 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \ ...@@ -11,6 +11,7 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
timer_int.o ) timer_int.o )
oprofile-y := $(DRIVER_OBJS) common.o backtrace.o oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
oprofile-$(CONFIG_PPC_CELL) += op_model_cell.o
oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o
oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
oprofile-$(CONFIG_6xx) += op_model_7450.o oprofile-$(CONFIG_6xx) += op_model_7450.o
...@@ -69,7 +69,10 @@ static void op_powerpc_cpu_start(void *dummy) ...@@ -69,7 +69,10 @@ static void op_powerpc_cpu_start(void *dummy)
static int op_powerpc_start(void) static int op_powerpc_start(void)
{ {
on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1); if (model->global_start)
model->global_start(ctr);
if (model->start)
on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1);
return 0; return 0;
} }
...@@ -80,7 +83,10 @@ static inline void op_powerpc_cpu_stop(void *dummy) ...@@ -80,7 +83,10 @@ static inline void op_powerpc_cpu_stop(void *dummy)
static void op_powerpc_stop(void) static void op_powerpc_stop(void)
{ {
on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1); if (model->stop)
on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1);
if (model->global_stop)
model->global_stop();
} }
static int op_powerpc_create_files(struct super_block *sb, struct dentry *root) static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
...@@ -141,6 +147,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) ...@@ -141,6 +147,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
switch (cur_cpu_spec->oprofile_type) { switch (cur_cpu_spec->oprofile_type) {
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#ifdef CONFIG_PPC_CELL
case PPC_OPROFILE_CELL:
model = &op_model_cell;
break;
#endif
case PPC_OPROFILE_RS64: case PPC_OPROFILE_RS64:
model = &op_model_rs64; model = &op_model_rs64;
break; break;
......
This diff is collapsed.
...@@ -130,6 +130,18 @@ struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu) ...@@ -130,6 +130,18 @@ struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu)
} }
EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs); EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs);
/* FIXME
* This is little more than a stub at the moment. It should be
* fleshed out so that it works for both SMT and non-SMT, no
* matter if the passed cpu is odd or even.
* For SMT enabled, returns 0 for even-numbered cpu; otherwise 1.
* For SMT disabled, returns 0 for all cpus.
*/
u32 cbe_get_hw_thread_id(int cpu)
{
return (cpu & 1);
}
EXPORT_SYMBOL_GPL(cbe_get_hw_thread_id);
void __init cbe_regs_init(void) void __init cbe_regs_init(void)
{ {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/types.h> #include <linux/types.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq_regs.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/pmc.h> #include <asm/pmc.h>
#include <asm/reg.h> #include <asm/reg.h>
...@@ -375,9 +376,9 @@ void cbe_disable_pm_interrupts(u32 cpu) ...@@ -375,9 +376,9 @@ void cbe_disable_pm_interrupts(u32 cpu)
} }
EXPORT_SYMBOL_GPL(cbe_disable_pm_interrupts); EXPORT_SYMBOL_GPL(cbe_disable_pm_interrupts);
static irqreturn_t cbe_pm_irq(int irq, void *dev_id, struct pt_regs *regs) static irqreturn_t cbe_pm_irq(int irq, void *dev_id)
{ {
perf_irq(regs); perf_irq(get_irq_regs());
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -408,3 +409,21 @@ int __init cbe_init_pm_irq(void) ...@@ -408,3 +409,21 @@ int __init cbe_init_pm_irq(void)
} }
arch_initcall(cbe_init_pm_irq); arch_initcall(cbe_init_pm_irq);
void cbe_sync_irq(int node)
{
unsigned int irq;
irq = irq_find_mapping(NULL,
IIC_IRQ_IOEX_PMI
| (node << IIC_IRQ_NODE_SHIFT));
if (irq == NO_IRQ) {
printk(KERN_WARNING "ERROR, unable to get existing irq %d " \
"for node %d\n", irq, node);
return;
}
synchronize_irq(irq);
}
EXPORT_SYMBOL_GPL(cbe_sync_irq);
...@@ -91,5 +91,23 @@ extern void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask); ...@@ -91,5 +91,23 @@ extern void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
extern void cbe_disable_pm_interrupts(u32 cpu); extern void cbe_disable_pm_interrupts(u32 cpu);
extern u32 cbe_query_pm_interrupts(u32 cpu); extern u32 cbe_query_pm_interrupts(u32 cpu);
extern u32 cbe_clear_pm_interrupts(u32 cpu); extern u32 cbe_clear_pm_interrupts(u32 cpu);
extern void cbe_sync_irq(int node);
/* Utility functions, macros */
extern u32 cbe_get_hw_thread_id(int cpu);
#define cbe_cpu_to_node(cpu) ((cpu) >> 1)
#define CBE_COUNT_SUPERVISOR_MODE 0
#define CBE_COUNT_HYPERVISOR_MODE 1
#define CBE_COUNT_PROBLEM_MODE 2
#define CBE_COUNT_ALL_MODES 3
/* Macros for the pm07_control registers. */
#define PM07_CTR_INPUT_MUX(x) (((x) & 0x3F) << 26)
#define PM07_CTR_INPUT_CONTROL(x) (((x) & 1) << 25)
#define PM07_CTR_POLARITY(x) (((x) & 1) << 24)
#define PM07_CTR_COUNT_CYCLES(x) (((x) & 1) << 23)
#define PM07_CTR_ENABLE(x) (((x) & 1) << 22)
#endif /* __ASM_CELL_PMU_H__ */ #endif /* __ASM_CELL_PMU_H__ */
...@@ -45,6 +45,7 @@ enum powerpc_oprofile_type { ...@@ -45,6 +45,7 @@ enum powerpc_oprofile_type {
PPC_OPROFILE_POWER4 = 2, PPC_OPROFILE_POWER4 = 2,
PPC_OPROFILE_G4 = 3, PPC_OPROFILE_G4 = 3,
PPC_OPROFILE_BOOKE = 4, PPC_OPROFILE_BOOKE = 4,
PPC_OPROFILE_CELL = 5,
}; };
struct cpu_spec { struct cpu_spec {
......
...@@ -44,7 +44,9 @@ struct op_powerpc_model { ...@@ -44,7 +44,9 @@ struct op_powerpc_model {
int num_counters); int num_counters);
void (*cpu_setup) (struct op_counter_config *); void (*cpu_setup) (struct op_counter_config *);
void (*start) (struct op_counter_config *); void (*start) (struct op_counter_config *);
void (*global_start) (struct op_counter_config *);
void (*stop) (void); void (*stop) (void);
void (*global_stop) (void);
void (*handle_interrupt) (struct pt_regs *, void (*handle_interrupt) (struct pt_regs *,
struct op_counter_config *); struct op_counter_config *);
int num_counters; int num_counters;
...@@ -54,6 +56,7 @@ extern struct op_powerpc_model op_model_fsl_booke; ...@@ -54,6 +56,7 @@ extern struct op_powerpc_model op_model_fsl_booke;
extern struct op_powerpc_model op_model_rs64; extern struct op_powerpc_model op_model_rs64;
extern struct op_powerpc_model op_model_power4; extern struct op_powerpc_model op_model_power4;
extern struct op_powerpc_model op_model_7450; extern struct op_powerpc_model op_model_7450;
extern struct op_powerpc_model op_model_cell;
#ifndef CONFIG_FSL_BOOKE #ifndef CONFIG_FSL_BOOKE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment