lkml.org 
[lkml]   [2008]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] ftrace: use code patching for ftrace graph tracer
On Wed, 26 Nov 2008 00:16:24 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <rostedt@goodmis.org>
>
> Impact: more efficient code for ftrace graph tracer
>
> This patch uses the dynamic patching, when available, to patch
> the function graph code into the kernel.
>
> This patch will ease the way for letting both function tracing
> and function graph tracing run together.
>
> ...
>
> +static int ftrace_mod_jmp(unsigned long ip,
> + int old_offset, int new_offset)
> +{
> + unsigned char code[MCOUNT_INSN_SIZE];
> +
> + if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
> + return -EFAULT;
> +
> + if (code[0] != 0xe9 || old_offset != *(int *)(&code[1]))

erk. I suspect that there's a nicer way of doing this amongst our
forest of get_unaligned_foo() interfaces. Harvey will know.

> + return -EINVAL;
> +
> + *(int *)(&code[1]) = new_offset;

Might be able to use put_unaligned_foo() here.

The problem is that these functions use sizeof(*ptr) to work out what
to do, so a cast is still needed. A get_unaligned32(ptr) would be
nice. One which takes a void* and assumes CPU ordering.

> + if (do_ftrace_mod_code(ip, &code))
> + return -EPERM;
> +
> + return 0;
> +}
> +



\
 
 \ /
  Last update: 2008-11-26 06:39    [W:0.223 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site