提交 0c0a400d 编写于 作者: J John Levon 提交者: Linus Torvalds

[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: NJohn Levon <levon@movementarian.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 391cd727
...@@ -63,7 +63,7 @@ o PPP 2.4.0 # pppd --version ...@@ -63,7 +63,7 @@ o PPP 2.4.0 # pppd --version
o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version
o nfs-utils 1.0.5 # showmount --version o nfs-utils 1.0.5 # showmount --version
o procps 3.2.0 # ps --version o procps 3.2.0 # ps --version
o oprofile 0.5.3 # oprofiled --version o oprofile 0.9 # oprofiled --version
Kernel compilation Kernel compilation
================== ==================
......
...@@ -27,9 +27,13 @@ dump output readprofile -m /boot/System.map > captured_profile ...@@ -27,9 +27,13 @@ dump output readprofile -m /boot/System.map > captured_profile
Oprofile Oprofile
-------- --------
Get the source (I use 0.8) from http://oprofile.sourceforge.net/
and add "idle=poll" to the kernel command line Get the source (see Changes for required version) from
http://oprofile.sourceforge.net/ and add "idle=poll" to the kernel command
line.
Configure with CONFIG_PROFILING=y and CONFIG_OPROFILE=y & reboot on new kernel Configure with CONFIG_PROFILING=y and CONFIG_OPROFILE=y & reboot on new kernel
./configure --with-kernel-support ./configure --with-kernel-support
make install make install
...@@ -46,7 +50,7 @@ start opcontrol --start ...@@ -46,7 +50,7 @@ start opcontrol --start
stop opcontrol --stop stop opcontrol --stop
dump output opreport > output_file dump output opreport > output_file
To only report on the kernel, run opreport /boot/vmlinux > output_file To only report on the kernel, run opreport -l /boot/vmlinux > output_file
A reset is needed to clear old statistics, which survive a reboot. A reset is needed to clear old statistics, which survive a reboot.
...@@ -206,7 +206,7 @@ static inline unsigned long fast_get_dcookie(struct dentry * dentry, ...@@ -206,7 +206,7 @@ static inline unsigned long fast_get_dcookie(struct dentry * dentry,
*/ */
static unsigned long get_exec_dcookie(struct mm_struct * mm) static unsigned long get_exec_dcookie(struct mm_struct * mm)
{ {
unsigned long cookie = 0; unsigned long cookie = NO_COOKIE;
struct vm_area_struct * vma; struct vm_area_struct * vma;
if (!mm) if (!mm)
...@@ -234,35 +234,42 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm) ...@@ -234,35 +234,42 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm)
*/ */
static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, off_t * offset) 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; struct vm_area_struct * vma;
for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) { 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) if (addr < vma->vm_start || addr >= vma->vm_end)
continue; continue;
cookie = fast_get_dcookie(vma->vm_file->f_dentry, if (vma->vm_file) {
vma->vm_file->f_vfsmnt); cookie = fast_get_dcookie(vma->vm_file->f_dentry,
*offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - vma->vm_start; vma->vm_file->f_vfsmnt);
*offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
vma->vm_start;
} else {
/* must be an anonymous map */
*offset = addr;
}
break; break;
} }
if (!vma)
cookie = INVALID_COOKIE;
return cookie; return cookie;
} }
static unsigned long last_cookie = ~0UL; static unsigned long last_cookie = INVALID_COOKIE;
static void add_cpu_switch(int i) static void add_cpu_switch(int i)
{ {
add_event_entry(ESCAPE_CODE); add_event_entry(ESCAPE_CODE);
add_event_entry(CPU_SWITCH_CODE); add_event_entry(CPU_SWITCH_CODE);
add_event_entry(i); add_event_entry(i);
last_cookie = ~0UL; last_cookie = INVALID_COOKIE;
} }
static void add_kernel_ctx_switch(unsigned int in_kernel) 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) ...@@ -317,7 +324,7 @@ static int add_us_sample(struct mm_struct * mm, struct op_sample * s)
cookie = lookup_dcookie(mm, s->eip, &offset); cookie = lookup_dcookie(mm, s->eip, &offset);
if (!cookie) { if (cookie == INVALID_COOKIE) {
atomic_inc(&oprofile_stats.sample_lost_no_mapping); atomic_inc(&oprofile_stats.sample_lost_no_mapping);
return 0; return 0;
} }
......
...@@ -35,6 +35,9 @@ void wake_up_buffer_waiter(void); ...@@ -35,6 +35,9 @@ void wake_up_buffer_waiter(void);
#define TRACE_BEGIN_CODE 8 #define TRACE_BEGIN_CODE 8
#define TRACE_END_CODE 9 #define TRACE_END_CODE 9
#define INVALID_COOKIE ~0UL
#define NO_COOKIE 0UL
/* add data to the event buffer */ /* add data to the event buffer */
void add_event_entry(unsigned long data); void add_event_entry(unsigned long data);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册