aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oprofile')
-rw-r--r--drivers/oprofile/buffer_sync.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index d295d92b57f0..0abe29e7e4c7 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -392,11 +392,29 @@ static void add_sample_entry(unsigned long offset, unsigned long event)
392} 392}
393 393
394 394
395static int add_us_sample(struct mm_struct *mm, struct op_sample *s) 395/*
396 * Add a sample to the global event buffer. If possible the
397 * sample is converted into a persistent dentry/offset pair
398 * for later lookup from userspace. Return 0 on failure.
399 */
400static int
401add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
396{ 402{
397 unsigned long cookie; 403 unsigned long cookie;
398 off_t offset; 404 off_t offset;
399 405
406 if (in_kernel) {
407 add_sample_entry(s->eip, s->event);
408 return 1;
409 }
410
411 /* add userspace sample */
412
413 if (!mm) {
414 atomic_inc(&oprofile_stats.sample_lost_no_mm);
415 return 0;
416 }
417
400 cookie = lookup_dcookie(mm, s->eip, &offset); 418 cookie = lookup_dcookie(mm, s->eip, &offset);
401 419
402 if (cookie == INVALID_COOKIE) { 420 if (cookie == INVALID_COOKIE) {
@@ -415,25 +433,6 @@ static int add_us_sample(struct mm_struct *mm, struct op_sample *s)
415} 433}
416 434
417 435
418/* Add a sample to the global event buffer. If possible the
419 * sample is converted into a persistent dentry/offset pair
420 * for later lookup from userspace.
421 */
422static int
423add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
424{
425 if (in_kernel) {
426 add_sample_entry(s->eip, s->event);
427 return 1;
428 } else if (mm) {
429 return add_us_sample(mm, s);
430 } else {
431 atomic_inc(&oprofile_stats.sample_lost_no_mm);
432 }
433 return 0;
434}
435
436
437static void release_mm(struct mm_struct *mm) 436static void release_mm(struct mm_struct *mm)
438{ 437{
439 if (!mm) 438 if (!mm)