Skip to content

Commit 4ce5f24

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile: (31 commits) powerpc/oprofile: fix whitespaces in op_model_cell.c powerpc/oprofile: IBM CELL: add SPU event profiling support powerpc/oprofile: fix cell/pr_util.h powerpc/oprofile: IBM CELL: cleanup and restructuring oprofile: make new cpu buffer functions part of the api oprofile: remove #ifdef CONFIG_OPROFILE_IBS in non-ibs code ring_buffer: fix ring_buffer_event_length() oprofile: use new data sample format for ibs oprofile: add op_cpu_buffer_get_data() oprofile: add op_cpu_buffer_add_data() oprofile: rework implementation of cpu buffer events oprofile: modify op_cpu_buffer_read_entry() oprofile: add op_cpu_buffer_write_reserve() oprofile: rename variables in add_ibs_begin() oprofile: rename add_sample() in cpu_buffer.c oprofile: rename variable ibs_allowed to has_ibs in op_model_amd.c oprofile: making add_sample_entry() inline oprofile: remove backtrace code for ibs oprofile: remove unused ibs macro oprofile: remove unused components in struct oprofile_cpu_buffer ...
2 parents 7c51d57 + a076aa4 commit 4ce5f24

File tree

16 files changed

+1122
-534
lines changed

16 files changed

+1122
-534
lines changed

arch/powerpc/include/asm/cell-pmu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
#define CBE_PM_STOP_AT_MAX 0x40000000
3838
#define CBE_PM_TRACE_MODE_GET(pm_control) (((pm_control) >> 28) & 0x3)
3939
#define CBE_PM_TRACE_MODE_SET(mode) (((mode) & 0x3) << 28)
40+
#define CBE_PM_TRACE_BUF_OVFLW(bit) (((bit) & 0x1) << 17)
4041
#define CBE_PM_COUNT_MODE_SET(count) (((count) & 0x3) << 18)
4142
#define CBE_PM_FREEZE_ALL_CTRS 0x00100000
4243
#define CBE_PM_ENABLE_EXT_TRACE 0x00008000
44+
#define CBE_PM_SPU_ADDR_TRACE_SET(msk) (((msk) & 0x3) << 9)
4345

4446
/* Macros for the trace_address register. */
4547
#define CBE_PM_TRACE_BUF_FULL 0x00000800

arch/powerpc/include/asm/oprofile_impl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ struct op_system_config {
3232
unsigned long mmcr0;
3333
unsigned long mmcr1;
3434
unsigned long mmcra;
35+
#ifdef CONFIG_OPROFILE_CELL
36+
/* Register for oprofile user tool to check cell kernel profiling
37+
* suport.
38+
*/
39+
unsigned long cell_support;
40+
#endif
3541
#endif
3642
unsigned long enable_kernel;
3743
unsigned long enable_user;

arch/powerpc/oprofile/cell/pr_util.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
extern struct delayed_work spu_work;
3131
extern int spu_prof_running;
3232

33+
#define TRACE_ARRAY_SIZE 1024
34+
35+
extern spinlock_t oprof_spu_smpl_arry_lck;
36+
3337
struct spu_overlay_info { /* map of sections within an SPU overlay */
3438
unsigned int vma; /* SPU virtual memory address from elf */
3539
unsigned int size; /* size of section from elf */
@@ -89,10 +93,11 @@ void vma_map_free(struct vma_to_fileoffset_map *map);
8993
* Entry point for SPU profiling.
9094
* cycles_reset is the SPU_CYCLES count value specified by the user.
9195
*/
92-
int start_spu_profiling(unsigned int cycles_reset);
93-
94-
void stop_spu_profiling(void);
96+
int start_spu_profiling_cycles(unsigned int cycles_reset);
97+
void start_spu_profiling_events(void);
9598

99+
void stop_spu_profiling_cycles(void);
100+
void stop_spu_profiling_events(void);
96101

97102
/* add the necessary profiling hooks */
98103
int spu_sync_start(void);

arch/powerpc/oprofile/cell/spu_profiler.c

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@
1818
#include <asm/cell-pmu.h>
1919
#include "pr_util.h"
2020

21-
#define TRACE_ARRAY_SIZE 1024
2221
#define SCALE_SHIFT 14
2322

2423
static u32 *samples;
2524

25+
/* spu_prof_running is a flag used to indicate if spu profiling is enabled
26+
* or not. It is set by the routines start_spu_profiling_cycles() and
27+
* start_spu_profiling_events(). The flag is cleared by the routines
28+
* stop_spu_profiling_cycles() and stop_spu_profiling_events(). These
29+
* routines are called via global_start() and global_stop() which are called in
30+
* op_powerpc_start() and op_powerpc_stop(). These routines are called once
31+
* per system as a result of the user starting/stopping oprofile. Hence, only
32+
* one CPU per user at a time will be changing the value of spu_prof_running.
33+
* In general, OProfile does not protect against multiple users trying to run
34+
* OProfile at a time.
35+
*/
2636
int spu_prof_running;
2737
static unsigned int profiling_interval;
2838

@@ -31,8 +41,8 @@ static unsigned int profiling_interval;
3141

3242
#define SPU_PC_MASK 0xFFFF
3343

34-
static DEFINE_SPINLOCK(sample_array_lock);
35-
unsigned long sample_array_lock_flags;
44+
DEFINE_SPINLOCK(oprof_spu_smpl_arry_lck);
45+
unsigned long oprof_spu_smpl_arry_lck_flags;
3646

3747
void set_spu_profiling_frequency(unsigned int freq_khz, unsigned int cycles_reset)
3848
{
@@ -145,13 +155,13 @@ static enum hrtimer_restart profile_spus(struct hrtimer *timer)
145155
* sample array must be loaded and then processed for a given
146156
* cpu. The sample array is not per cpu.
147157
*/
148-
spin_lock_irqsave(&sample_array_lock,
149-
sample_array_lock_flags);
158+
spin_lock_irqsave(&oprof_spu_smpl_arry_lck,
159+
oprof_spu_smpl_arry_lck_flags);
150160
num_samples = cell_spu_pc_collection(cpu);
151161

152162
if (num_samples == 0) {
153-
spin_unlock_irqrestore(&sample_array_lock,
154-
sample_array_lock_flags);
163+
spin_unlock_irqrestore(&oprof_spu_smpl_arry_lck,
164+
oprof_spu_smpl_arry_lck_flags);
155165
continue;
156166
}
157167

@@ -162,8 +172,8 @@ static enum hrtimer_restart profile_spus(struct hrtimer *timer)
162172
num_samples);
163173
}
164174

165-
spin_unlock_irqrestore(&sample_array_lock,
166-
sample_array_lock_flags);
175+
spin_unlock_irqrestore(&oprof_spu_smpl_arry_lck,
176+
oprof_spu_smpl_arry_lck_flags);
167177

168178
}
169179
smp_wmb(); /* insure spu event buffer updates are written */
@@ -182,13 +192,13 @@ static enum hrtimer_restart profile_spus(struct hrtimer *timer)
182192

183193
static struct hrtimer timer;
184194
/*
185-
* Entry point for SPU profiling.
195+
* Entry point for SPU cycle profiling.
186196
* NOTE: SPU profiling is done system-wide, not per-CPU.
187197
*
188198
* cycles_reset is the count value specified by the user when
189199
* setting up OProfile to count SPU_CYCLES.
190200
*/
191-
int start_spu_profiling(unsigned int cycles_reset)
201+
int start_spu_profiling_cycles(unsigned int cycles_reset)
192202
{
193203
ktime_t kt;
194204

@@ -212,10 +222,30 @@ int start_spu_profiling(unsigned int cycles_reset)
212222
return 0;
213223
}
214224

215-
void stop_spu_profiling(void)
225+
/*
226+
* Entry point for SPU event profiling.
227+
* NOTE: SPU profiling is done system-wide, not per-CPU.
228+
*
229+
* cycles_reset is the count value specified by the user when
230+
* setting up OProfile to count SPU_CYCLES.
231+
*/
232+
void start_spu_profiling_events(void)
233+
{
234+
spu_prof_running = 1;
235+
schedule_delayed_work(&spu_work, DEFAULT_TIMER_EXPIRE);
236+
237+
return;
238+
}
239+
240+
void stop_spu_profiling_cycles(void)
216241
{
217242
spu_prof_running = 0;
218243
hrtimer_cancel(&timer);
219244
kfree(samples);
220-
pr_debug("SPU_PROF: stop_spu_profiling issued\n");
245+
pr_debug("SPU_PROF: stop_spu_profiling_cycles issued\n");
246+
}
247+
248+
void stop_spu_profiling_events(void)
249+
{
250+
spu_prof_running = 0;
221251
}

arch/powerpc/oprofile/common.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,28 @@ static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
132132
oprofilefs_create_ulong(sb, root, "mmcr0", &sys.mmcr0);
133133
oprofilefs_create_ulong(sb, root, "mmcr1", &sys.mmcr1);
134134
oprofilefs_create_ulong(sb, root, "mmcra", &sys.mmcra);
135+
#ifdef CONFIG_OPROFILE_CELL
136+
/* create a file the user tool can check to see what level of profiling
137+
* support exits with this kernel. Initialize bit mask to indicate
138+
* what support the kernel has:
139+
* bit 0 - Supports SPU event profiling in addition to PPU
140+
* event and cycles; and SPU cycle profiling
141+
* bits 1-31 - Currently unused.
142+
*
143+
* If the file does not exist, then the kernel only supports SPU
144+
* cycle profiling, PPU event and cycle profiling.
145+
*/
146+
oprofilefs_create_ulong(sb, root, "cell_support", &sys.cell_support);
147+
sys.cell_support = 0x1; /* Note, the user OProfile tool must check
148+
* that this bit is set before attempting to
149+
* user SPU event profiling. Older kernels
150+
* will not have this file, hence the user
151+
* tool is not allowed to do SPU event
152+
* profiling on older kernels. Older kernels
153+
* will accept SPU events but collected data
154+
* is garbage.
155+
*/
156+
#endif
135157
#endif
136158

137159
for (i = 0; i < model->num_counters; ++i) {

0 commit comments

Comments
 (0)