Skip to content

Commit

Permalink
[POWERPC] cell: Add oprofile support
Browse files Browse the repository at this point in the history
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: Carl Love <carll@us.ibm.com>
Signed-off-by: Maynard Johnson <mpjohn@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Maynard Johnson authored and Paul Mackerras committed Dec 4, 2006
1 parent 0443bbd commit 18f2190
Show file tree
Hide file tree
Showing 10 changed files with 798 additions and 5 deletions.
3 changes: 2 additions & 1 deletion arch/powerpc/configs/cell_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,8 @@ CONFIG_PLIST=y
#
# Instrumentation Support
#
# CONFIG_PROFILING is not set
CONFIG_PROFILING=y
CONFIG_OPROFILE=y
# CONFIG_KPROBES is not set

#
Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/kernel/cputable.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ static struct cpu_spec cpu_specs[] = {
PPC_FEATURE_SMT,
.icache_bsize = 128,
.dcache_bsize = 128,
.num_pmcs = 4,
.oprofile_cpu_type = "ppc64/cell-be",
.oprofile_type = PPC_OPROFILE_CELL,
.platform = "ppc-cell-be",
},
{ /* PA Semi PA6T */
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/oprofile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
timer_int.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_FSL_BOOKE) += op_model_fsl_booke.o
oprofile-$(CONFIG_6xx) += op_model_7450.o
15 changes: 13 additions & 2 deletions arch/powerpc/oprofile/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ static void op_powerpc_cpu_start(void *dummy)

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;
}

Expand All @@ -80,7 +83,10 @@ static inline void op_powerpc_cpu_stop(void *dummy)

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)
Expand Down Expand Up @@ -141,6 +147,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)

switch (cur_cpu_spec->oprofile_type) {
#ifdef CONFIG_PPC64
#ifdef CONFIG_PPC_CELL
case PPC_OPROFILE_CELL:
model = &op_model_cell;
break;
#endif
case PPC_OPROFILE_RS64:
model = &op_model_rs64;
break;
Expand Down
Loading

0 comments on commit 18f2190

Please sign in to comment.