ftrace: sysprof fix

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
Ingo Molnar 2008-05-12 21:20:48 +02:00 committed by Thomas Gleixner
parent ef4ab15ff3
commit 9f6b4e3f4a
1 changed files with 19 additions and 9 deletions

View File

@ -37,21 +37,26 @@ struct stack_frame {
static int copy_stack_frame(const void __user *fp, struct stack_frame *frame) static int copy_stack_frame(const void __user *fp, struct stack_frame *frame)
{ {
int ret;
if (!access_ok(VERIFY_READ, fp, sizeof(*frame))) if (!access_ok(VERIFY_READ, fp, sizeof(*frame)))
return 0; return 0;
if (__copy_from_user_inatomic(frame, frame_pointer, sizeof(*frame))) ret = 1;
return 0; pagefault_disable();
if (__copy_from_user_inatomic(frame, fp, sizeof(*frame)))
ret = 0;
pagefault_enable();
return 1; return ret;
} }
static void timer_notify(struct pt_regs *regs, int cpu) static void timer_notify(struct pt_regs *regs, int cpu)
{ {
const void __user *frame_pointer;
struct trace_array_cpu *data; struct trace_array_cpu *data;
struct stack_frame frame; struct stack_frame frame;
struct trace_array *tr; struct trace_array *tr;
const void __user *fp;
int is_user; int is_user;
int i; int i;
@ -77,21 +82,26 @@ static void timer_notify(struct pt_regs *regs, int cpu)
trace_special(tr, data, 0, current->pid, regs->ip); trace_special(tr, data, 0, current->pid, regs->ip);
frame_pointer = (void __user *)regs->bp; fp = (void __user *)regs->bp;
for (i = 0; i < sample_max_depth; i++) { for (i = 0; i < sample_max_depth; i++) {
if (!copy_stack_frame(frame_pointer, &frame)) frame.next_fp = 0;
frame.return_address = 0;
if (!copy_stack_frame(fp, &frame))
break; break;
if ((unsigned long)frame_pointer < regs->sp) if ((unsigned long)fp < regs->sp)
break; break;
trace_special(tr, data, 1, frame.return_address, trace_special(tr, data, 1, frame.return_address,
(unsigned long)frame_pointer); (unsigned long)fp);
frame_pointer = frame.next_fp; fp = frame.next_fp;
} }
trace_special(tr, data, 2, current->pid, i); trace_special(tr, data, 2, current->pid, i);
/*
* Special trace entry if we overflow the max depth:
*/
if (i == sample_max_depth) if (i == sample_max_depth)
trace_special(tr, data, -1, -1, -1); trace_special(tr, data, -1, -1, -1);
} }