lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Question about ftrace, dynamically allocated trampolines and dynamic fops
On Thu, 29 Jan 2015 10:40:58 +0100 (CET)
Miroslav Benes <mbenes@suse.cz> wrote:

>
> Hi,
>
> solving a possible race condition in kGraft and thinking about the same in
> klp live patching I looked quite a lot at ftrace code. One thing about
> recent dynamic trampolines seems a bit odd. For dynamic fops
> (FTRACE_OPS_FL_DYNAMIC is set in ops->flags) arch_ftrace_update_trampoline
> is called only for nonpreemptive kernels in ftrace_update_trampoline. The
> reason is obvious and well described in the comment there. However the
> actual callback function in arch_ftrace_update_trampoline is
> determined by call to ftrace_ops_get_func which gives generic
> ftrace_ops_list_func for dynamic ops. This function disables preemption
> (because of traversing rcu protected list), so it should be safe to use
> dynamic trampolines even for dynamic fops in preemptive kernels. Is this
> correct?

No, the dynamic trampoline itself is not safe. I explained this at the
LinuxConEU/Plumbers conference, although the slides don't explain it
well :-/, otherwise I would have just pointed you to them.

Basically what the issue is, if a task jumps to the dynamic trampoline
and gets preempted, how would you ever free that trampoline again?

Now for live kernel patching, we could add another flag that says
permanent, that means the trampoline and the ops will never be free or
change, and then it would be safe to use dynamic trampolines.

>
> Or maybe the problem is the opposite. Why does the ftrace use
> ftrace_ops_list_func in such situation? Even for nonpreemptive kernel and
> dynamic fops ftrace_ops_list_func has unnecessary overhead.

It points the dynamic ops (in non-preempt) to ftrace_ops_list_func? Are
you sure about that. One way to verify is to
cat /sys/kernel/debug/tracing/enabled_functions, which should show you
want the dynamic ops points to.

-- Steve


\
 
 \ /
  Last update: 2015-01-29 16:01    [W:0.051 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site