summaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/cpu_buffer.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2009-01-05 10:35:31 +0100
committerRobert Richter <robert.richter@amd.com>2009-01-07 22:47:23 +0100
commit1acda878e20ea0cd3708ba66dca67d52eaafdd2b (patch)
tree97eb93396efc357f91dbd0ce080a5df51f29fd9b /drivers/oprofile/cpu_buffer.c
parentbd7dc46f770d317ada1348294ff1f319243b803b (diff)
downloadop-kernel-dev-1acda878e20ea0cd3708ba66dca67d52eaafdd2b.zip
op-kernel-dev-1acda878e20ea0cd3708ba66dca67d52eaafdd2b.tar.gz
oprofile: use new data sample format for ibs
The new ring buffer implementation allows the storage of samples with different size. This patch implements the usage of the new sample format to store ibs samples in the cpu buffer. Until now, writing to the cpu buffer could lead to incomplete sampling sequences since IBS samples were transfered in multiple samples. Due to a full buffer, data could be lost at any time. This can't happen any more since the complete data is reserved in advance and then stored in a single sample. Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile/cpu_buffer.c')
-rw-r--r--drivers/oprofile/cpu_buffer.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 1b65907..ddba9d0 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -363,31 +363,38 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
#ifdef CONFIG_OPROFILE_IBS
-void oprofile_add_ibs_sample(struct pt_regs * const regs,
- unsigned int * const ibs_sample, int ibs_code)
+/*
+ * Add samples with data to the ring buffer.
+ *
+ * Use op_cpu_buffer_add_data(&entry, val) to add data and
+ * op_cpu_buffer_write_commit(&entry) to commit the sample.
+ */
+void oprofile_add_data(struct op_entry *entry, struct pt_regs * const regs,
+ unsigned long pc, int code, int size)
{
+ struct op_sample *sample;
int is_kernel = !user_mode(regs);
struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
- int fail = 0;
cpu_buf->sample_received++;
- /* backtraces disabled for ibs */
- fail = fail || op_add_code(cpu_buf, 0, is_kernel, current);
+ /* no backtraces for samples with data */
+ if (op_add_code(cpu_buf, 0, is_kernel, current))
+ goto fail;
- fail = fail || op_add_sample(cpu_buf, ESCAPE_CODE, ibs_code);
- fail = fail || op_add_sample(cpu_buf, ibs_sample[0], ibs_sample[1]);
- fail = fail || op_add_sample(cpu_buf, ibs_sample[2], ibs_sample[3]);
- fail = fail || op_add_sample(cpu_buf, ibs_sample[4], ibs_sample[5]);
+ sample = op_cpu_buffer_write_reserve(entry, size + 2);
+ if (!sample)
+ goto fail;
+ sample->eip = ESCAPE_CODE;
+ sample->event = 0; /* no flags */
- if (ibs_code == IBS_OP_BEGIN) {
- fail = fail || op_add_sample(cpu_buf, ibs_sample[6], ibs_sample[7]);
- fail = fail || op_add_sample(cpu_buf, ibs_sample[8], ibs_sample[9]);
- fail = fail || op_add_sample(cpu_buf, ibs_sample[10], ibs_sample[11]);
- }
+ op_cpu_buffer_add_data(entry, code);
+ op_cpu_buffer_add_data(entry, pc);
+
+ return;
- if (fail)
- cpu_buf->sample_lost_overflow++;
+fail:
+ cpu_buf->sample_lost_overflow++;
}
#endif
OpenPOWER on IntegriCloud