提交 089dd79d 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

perf_counter: Generate mmap events for install_special_mapping()

In order to track the vdso also generate mmap events for
install_special_mapping().
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 f7b6eb3f
...@@ -617,8 +617,13 @@ static inline int is_software_counter(struct perf_counter *counter) ...@@ -617,8 +617,13 @@ static inline int is_software_counter(struct perf_counter *counter)
extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64); extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64);
extern void perf_counter_mmap(unsigned long addr, unsigned long len, extern void __perf_counter_mmap(struct vm_area_struct *vma);
unsigned long pgoff, struct file *file);
static inline void perf_counter_mmap(struct vm_area_struct *vma)
{
if (vma->vm_flags & VM_EXEC)
__perf_counter_mmap(vma);
}
extern void perf_counter_comm(struct task_struct *tsk); extern void perf_counter_comm(struct task_struct *tsk);
extern void perf_counter_fork(struct task_struct *tsk); extern void perf_counter_fork(struct task_struct *tsk);
...@@ -668,10 +673,7 @@ static inline void ...@@ -668,10 +673,7 @@ static inline void
perf_swcounter_event(u32 event, u64 nr, int nmi, perf_swcounter_event(u32 event, u64 nr, int nmi,
struct pt_regs *regs, u64 addr) { } struct pt_regs *regs, u64 addr) { }
static inline void static inline void perf_counter_mmap(struct vm_area_struct *vma) { }
perf_counter_mmap(unsigned long addr, unsigned long len,
unsigned long pgoff, struct file *file) { }
static inline void perf_counter_comm(struct task_struct *tsk) { } static inline void perf_counter_comm(struct task_struct *tsk) { }
static inline void perf_counter_fork(struct task_struct *tsk) { } static inline void perf_counter_fork(struct task_struct *tsk) { }
static inline void perf_counter_init(void) { } static inline void perf_counter_init(void) { }
......
...@@ -2255,7 +2255,7 @@ static int perf_output_begin(struct perf_output_handle *handle, ...@@ -2255,7 +2255,7 @@ static int perf_output_begin(struct perf_output_handle *handle,
} }
static void perf_output_copy(struct perf_output_handle *handle, static void perf_output_copy(struct perf_output_handle *handle,
void *buf, unsigned int len) const void *buf, unsigned int len)
{ {
unsigned int pages_mask; unsigned int pages_mask;
unsigned int offset; unsigned int offset;
...@@ -2681,8 +2681,9 @@ void perf_counter_comm(struct task_struct *task) ...@@ -2681,8 +2681,9 @@ void perf_counter_comm(struct task_struct *task)
*/ */
struct perf_mmap_event { struct perf_mmap_event {
struct file *file; struct vm_area_struct *vma;
char *file_name;
const char *file_name;
int file_size; int file_size;
struct { struct {
...@@ -2744,11 +2745,12 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event) ...@@ -2744,11 +2745,12 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event)
{ {
struct perf_cpu_context *cpuctx; struct perf_cpu_context *cpuctx;
struct perf_counter_context *ctx; struct perf_counter_context *ctx;
struct file *file = mmap_event->file; struct vm_area_struct *vma = mmap_event->vma;
struct file *file = vma->vm_file;
unsigned int size; unsigned int size;
char tmp[16]; char tmp[16];
char *buf = NULL; char *buf = NULL;
char *name; const char *name;
if (file) { if (file) {
buf = kzalloc(PATH_MAX, GFP_KERNEL); buf = kzalloc(PATH_MAX, GFP_KERNEL);
...@@ -2762,6 +2764,15 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event) ...@@ -2762,6 +2764,15 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event)
goto got_name; goto got_name;
} }
} else { } else {
name = arch_vma_name(mmap_event->vma);
if (name)
goto got_name;
if (!vma->vm_mm) {
name = strncpy(tmp, "[vdso]", sizeof(tmp));
goto got_name;
}
name = strncpy(tmp, "//anon", sizeof(tmp)); name = strncpy(tmp, "//anon", sizeof(tmp));
goto got_name; goto got_name;
} }
...@@ -2791,8 +2802,7 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event) ...@@ -2791,8 +2802,7 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event)
kfree(buf); kfree(buf);
} }
void perf_counter_mmap(unsigned long addr, unsigned long len, void __perf_counter_mmap(struct vm_area_struct *vma)
unsigned long pgoff, struct file *file)
{ {
struct perf_mmap_event mmap_event; struct perf_mmap_event mmap_event;
...@@ -2800,12 +2810,12 @@ void perf_counter_mmap(unsigned long addr, unsigned long len, ...@@ -2800,12 +2810,12 @@ void perf_counter_mmap(unsigned long addr, unsigned long len,
return; return;
mmap_event = (struct perf_mmap_event){ mmap_event = (struct perf_mmap_event){
.file = file, .vma = vma,
.event = { .event = {
.header = { .type = PERF_EVENT_MMAP, }, .header = { .type = PERF_EVENT_MMAP, },
.start = addr, .start = vma->vm_start,
.len = len, .len = vma->vm_end - vma->vm_start,
.pgoff = pgoff, .pgoff = vma->vm_pgoff,
}, },
}; };
......
...@@ -1220,8 +1220,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, ...@@ -1220,8 +1220,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
if (correct_wcount) if (correct_wcount)
atomic_inc(&inode->i_writecount); atomic_inc(&inode->i_writecount);
out: out:
if (vm_flags & VM_EXEC) perf_counter_mmap(vma);
perf_counter_mmap(addr, len, pgoff, file);
mm->total_vm += len >> PAGE_SHIFT; mm->total_vm += len >> PAGE_SHIFT;
vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT); vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
...@@ -2309,6 +2308,8 @@ int install_special_mapping(struct mm_struct *mm, ...@@ -2309,6 +2308,8 @@ int install_special_mapping(struct mm_struct *mm,
mm->total_vm += len >> PAGE_SHIFT; mm->total_vm += len >> PAGE_SHIFT;
perf_counter_mmap(vma);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册