Skip to content

Commit 9741b30

Browse files
author
Robert Richter
committed
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>
1 parent d45d23b commit 9741b30

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

‎drivers/oprofile/buffer_sync.c‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,29 @@ static void add_sample_entry(unsigned long offset, unsigned long event)
392392
}
393393

394394

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)
396402
{
397403
unsigned long cookie;
398404
off_t offset;
399405

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+
400418
cookie = lookup_dcookie(mm, s->eip, &offset);
401419

402420
if (cookie == INVALID_COOKIE) {
@@ -415,25 +433,6 @@ static int add_us_sample(struct mm_struct *mm, struct op_sample *s)
415433
}
416434

417435

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-
437436
static void release_mm(struct mm_struct *mm)
438437
{
439438
if (!mm)

0 commit comments

Comments
 (0)