diff options
author | John Levon <levon@movementarian.org> | 2005-06-23 22:02:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 00:06:27 -0700 |
commit | 0c0a400d1debb172c596b24ab82efab4975990a9 (patch) | |
tree | 58bd3604e46151662268bd558dce49ac8e72cca0 /drivers/oprofile | |
parent | 391cd727eac2e10be7685efd739a3ea9de87393c (diff) | |
download | linux-0c0a400d1debb172c596b24ab82efab4975990a9.tar.gz linux-0c0a400d1debb172c596b24ab82efab4975990a9.tar.bz2 linux-0c0a400d1debb172c596b24ab82efab4975990a9.zip |
[PATCH] oprofile: report anonymous region samples
The below patch passes samples from anonymous regions to userspace instead
of just dropping them. This provides the support needed for reporting
anonymous-region code samples (today: basic accumulated results; later:
Java and other dynamically compiled code).
As this changes the format, an upgrade to the just-released 0.9 release of
the userspace tools is required.
This patch is based upon an earlier one by Will Cohen <wcohen@redhat.com>
Signed-off-by: John Levon <levon@movementarian.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/oprofile')
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 29 | ||||
-rw-r--r-- | drivers/oprofile/event_buffer.h | 3 |
2 files changed, 21 insertions, 11 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 745a14183634..531b07313141 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c @@ -206,7 +206,7 @@ static inline unsigned long fast_get_dcookie(struct dentry * dentry, */ static unsigned long get_exec_dcookie(struct mm_struct * mm) { - unsigned long cookie = 0; + unsigned long cookie = NO_COOKIE; struct vm_area_struct * vma; if (!mm) @@ -234,35 +234,42 @@ out: */ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, off_t * offset) { - unsigned long cookie = 0; + unsigned long cookie = NO_COOKIE; struct vm_area_struct * vma; for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) { - if (!vma->vm_file) - continue; - if (addr < vma->vm_start || addr >= vma->vm_end) continue; - cookie = fast_get_dcookie(vma->vm_file->f_dentry, - vma->vm_file->f_vfsmnt); - *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - vma->vm_start; + if (vma->vm_file) { + cookie = fast_get_dcookie(vma->vm_file->f_dentry, + vma->vm_file->f_vfsmnt); + *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - + vma->vm_start; + } else { + /* must be an anonymous map */ + *offset = addr; + } + break; } + if (!vma) + cookie = INVALID_COOKIE; + return cookie; } -static unsigned long last_cookie = ~0UL; +static unsigned long last_cookie = INVALID_COOKIE; static void add_cpu_switch(int i) { add_event_entry(ESCAPE_CODE); add_event_entry(CPU_SWITCH_CODE); add_event_entry(i); - last_cookie = ~0UL; + last_cookie = INVALID_COOKIE; } static void add_kernel_ctx_switch(unsigned int in_kernel) @@ -317,7 +324,7 @@ static int add_us_sample(struct mm_struct * mm, struct op_sample * s) cookie = lookup_dcookie(mm, s->eip, &offset); - if (!cookie) { + if (cookie == INVALID_COOKIE) { atomic_inc(&oprofile_stats.sample_lost_no_mapping); return 0; } diff --git a/drivers/oprofile/event_buffer.h b/drivers/oprofile/event_buffer.h index 442aaad391e0..018023630599 100644 --- a/drivers/oprofile/event_buffer.h +++ b/drivers/oprofile/event_buffer.h @@ -35,6 +35,9 @@ void wake_up_buffer_waiter(void); #define TRACE_BEGIN_CODE 8 #define TRACE_END_CODE 9 +#define INVALID_COOKIE ~0UL +#define NO_COOKIE 0UL + /* add data to the event buffer */ void add_event_entry(unsigned long data); |