diff options
author | Robert Richter <robert.richter@amd.com> | 2008-12-18 13:44:20 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2008-12-29 12:53:26 -0500 |
commit | 9741b309bb4493eedd3cdb5c97b566338a0da2cc (patch) | |
tree | 464db2c3b97daf69251a94d3589e3e6185910d80 /drivers/oprofile | |
parent | d45d23bed4bf7b25b7dcc336552a251db1aa1279 (diff) |
oprofile: simplify add_sample()
This patch removes add_us_sample() and simplifies add_sample(). Code
is much more readable now.
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile')
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 39 |
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 | ||
395 | static 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 | */ | ||
400 | static int | ||
401 | add_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 | */ | ||
422 | static int | ||
423 | add_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 | |||
437 | static void release_mm(struct mm_struct *mm) | 436 | static void release_mm(struct mm_struct *mm) |
438 | { | 437 | { |
439 | if (!mm) | 438 | if (!mm) |