aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/buffer_sync.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2009-01-05 04:35:31 -0500
committerRobert Richter <robert.richter@amd.com>2009-01-07 16:47:23 -0500
commit1acda878e20ea0cd3708ba66dca67d52eaafdd2b (patch)
tree97eb93396efc357f91dbd0ce080a5df51f29fd9b /drivers/oprofile/buffer_sync.c
parentbd7dc46f770d317ada1348294ff1f319243b803b (diff)
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/buffer_sync.c')
-rw-r--r--drivers/oprofile/buffer_sync.c53
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index f9031d31eeb7..d692fdc1a211 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -318,29 +318,18 @@ static void add_trace_begin(void)
318 318
319#ifdef CONFIG_OPROFILE_IBS 319#ifdef CONFIG_OPROFILE_IBS
320 320
321#define IBS_FETCH_CODE_SIZE 2 321static void add_data(struct op_entry *entry, struct mm_struct *mm)
322#define IBS_OP_CODE_SIZE 5
323
324/*
325 * Add IBS fetch and op entries to event buffer
326 */
327static void add_ibs_begin(int cpu, int code, struct mm_struct *mm)
328{ 322{
329 unsigned long pc; 323 unsigned long code, pc, val;
330 int i, count; 324 unsigned long cookie;
331 unsigned long cookie = 0;
332 off_t offset; 325 off_t offset;
333 struct op_entry entry;
334 struct op_sample *sample;
335 326
336 sample = op_cpu_buffer_read_entry(&entry, cpu); 327 if (!op_cpu_buffer_get_data(entry, &code))
337 if (!sample) 328 return;
329 if (!op_cpu_buffer_get_data(entry, &pc))
330 return;
331 if (!op_cpu_buffer_get_size(entry))
338 return; 332 return;
339 pc = sample->eip;
340
341#ifdef __LP64__
342 pc += sample->event << 32;
343#endif
344 333
345 if (mm) { 334 if (mm) {
346 cookie = lookup_dcookie(mm, pc, &offset); 335 cookie = lookup_dcookie(mm, pc, &offset);
@@ -362,24 +351,8 @@ static void add_ibs_begin(int cpu, int code, struct mm_struct *mm)
362 add_event_entry(code); 351 add_event_entry(code);
363 add_event_entry(offset); /* Offset from Dcookie */ 352 add_event_entry(offset); /* Offset from Dcookie */
364 353
365 /* we send the Dcookie offset, but send the raw Linear Add also*/ 354 while (op_cpu_buffer_get_data(entry, &val))
366 add_event_entry(sample->eip); 355 add_event_entry(val);
367 add_event_entry(sample->event);
368
369 if (code == IBS_FETCH_CODE)
370 count = IBS_FETCH_CODE_SIZE; /*IBS FETCH is 2 int64s*/
371 else
372 count = IBS_OP_CODE_SIZE; /*IBS OP is 5 int64s*/
373
374 for (i = 0; i < count; i++) {
375 sample = op_cpu_buffer_read_entry(&entry, cpu);
376 if (!sample)
377 return;
378 add_event_entry(sample->eip);
379 add_event_entry(sample->event);
380 }
381
382 return;
383} 356}
384 357
385#endif 358#endif
@@ -572,10 +545,8 @@ void sync_buffer(int cpu)
572 add_user_ctx_switch(new, cookie); 545 add_user_ctx_switch(new, cookie);
573 } 546 }
574#ifdef CONFIG_OPROFILE_IBS 547#ifdef CONFIG_OPROFILE_IBS
575 if (flags & IBS_FETCH_BEGIN) 548 if (op_cpu_buffer_get_size(&entry))
576 add_ibs_begin(cpu, IBS_FETCH_CODE, mm); 549 add_data(&entry, mm);
577 if (flags & IBS_OP_BEGIN)
578 add_ibs_begin(cpu, IBS_OP_CODE, mm);
579#endif 550#endif
580 continue; 551 continue;
581 } 552 }