From: Steven Rostedt <[email protected]>
With gcc 4.6, the self test kprobe function:
kprobe_trace_selftest_target()
is optimized such that kallsyms does not list it. The kprobes
test uses this function to insert a probe and test it. But
it will fail the test if the function is not listed in kallsyms.
Because the name is rather unique, converting it from static to
global should not be a problem. This prevents gcc from removing
it from kallsyms.
Cc: Masami Hiramatsu <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/trace/trace_kprobe.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index f925c45..2c14378 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1870,8 +1870,12 @@ fs_initcall(init_kprobe_trace);
#ifdef CONFIG_FTRACE_STARTUP_TEST
-static int kprobe_trace_selftest_target(int a1, int a2, int a3,
- int a4, int a5, int a6)
+/*
+ * Can't be static, otherwise gcc might optimize this to
+ * not be in the kallsyms table.
+ */
+int kprobe_trace_selftest_target(int a1, int a2, int a3,
+ int a4, int a5, int a6)
{
return a1 + a2 + a3 + a4 + a5 + a6;
}
--
1.7.4.4
On 06/07/2011 10:07 AM, Steven Rostedt wrote:
> From: Steven Rostedt<[email protected]>
>
> With gcc 4.6, the self test kprobe function:
>
> kprobe_trace_selftest_target()
>
> is optimized such that kallsyms does not list it. The kprobes
> test uses this function to insert a probe and test it. But
> it will fail the test if the function is not listed in kallsyms.
>
> Because the name is rather unique, converting it from static to
> global should not be a problem. This prevents gcc from removing
> it from kallsyms.
>
> Cc: Masami Hiramatsu<[email protected]>
> Signed-off-by: Steven Rostedt<[email protected]>
> ---
> kernel/trace/trace_kprobe.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index f925c45..2c14378 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -1870,8 +1870,12 @@ fs_initcall(init_kprobe_trace);
>
> #ifdef CONFIG_FTRACE_STARTUP_TEST
>
> -static int kprobe_trace_selftest_target(int a1, int a2, int a3,
> - int a4, int a5, int a6)
> +/*
> + * Can't be static, otherwise gcc might optimize this to
> + * not be in the kallsyms table.
> + */
Could you make it '__used' instead?
David Daney
> +int kprobe_trace_selftest_target(int a1, int a2, int a3,
> + int a4, int a5, int a6)
> {
> return a1 + a2 + a3 + a4 + a5 + a6;
> }
On Tue, 2011-06-07 at 11:08 -0700, David Daney wrote:
> > -static int kprobe_trace_selftest_target(int a1, int a2, int a3,
> > - int a4, int a5, int a6)
> > +/*
> > + * Can't be static, otherwise gcc might optimize this to
> > + * not be in the kallsyms table.
> > + */
>
> Could you make it '__used' instead?
>
I can try, but the problem is not that the function itself is being
optimized out. It looks like its being turned into anonymous text. That
is, it optimized out the symbol name, not the code itself.
-- Steve
On 06/07/2011 11:12 AM, Steven Rostedt wrote:
> On Tue, 2011-06-07 at 11:08 -0700, David Daney wrote:
>
>>> -static int kprobe_trace_selftest_target(int a1, int a2, int a3,
>>> - int a4, int a5, int a6)
>>> +/*
>>> + * Can't be static, otherwise gcc might optimize this to
>>> + * not be in the kallsyms table.
>>> + */
>>
>> Could you make it '__used' instead?
>>
>
> I can try, but the problem is not that the function itself is being
> optimized out. It looks like its being turned into anonymous text. That
> is, it optimized out the symbol name, not the code itself.
>
Really it is no big deal either way. Just a thought I had.
David Daney
On Tue, 2011-06-07 at 11:22 -0700, David Daney wrote:
> On 06/07/2011 11:12 AM, Steven Rostedt wrote:
> > On Tue, 2011-06-07 at 11:08 -0700, David Daney wrote:
> >
> >>> -static int kprobe_trace_selftest_target(int a1, int a2, int a3,
> >>> - int a4, int a5, int a6)
> >>> +/*
> >>> + * Can't be static, otherwise gcc might optimize this to
> >>> + * not be in the kallsyms table.
> >>> + */
> >>
> >> Could you make it '__used' instead?
> >>
> >
> > I can try, but the problem is not that the function itself is being
> > optimized out. It looks like its being turned into anonymous text. That
> > is, it optimized out the symbol name, not the code itself.
> >
>
> Really it is no big deal either way. Just a thought I had.
This actually works! I like it better.
Ingo, can you hold off on pulling, while I rebase to do it David's way?
I can add tested-by tags and fix misspellings of my other change logs as
well.
Thanks!
-- Steve