From: Oleg Nesterov <oleg@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Namhyung Kim <namhyung@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jiri Kosina <jkosina@suse.cz>,
Seth Jennings <sjenning@redhat.com>, Jiri Slaby <jslaby@suse.cz>
Subject: Re: [RFC][PATCH 0/3] ftrace: Add dynamically allocated trampolines
Date: Wed, 23 Jul 2014 19:05:52 +0200 [thread overview]
Message-ID: <20140723170552.GA7820@redhat.com> (raw)
In-Reply-To: <20140723114833.49170d63@gandalf.local.home>
On 07/23, Steven Rostedt wrote:
>
> On Wed, 23 Jul 2014 14:08:05 +0200
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > With this stupid patch
> >
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -4464,6 +4464,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> > printk("op=%p %pS\n", op, op);
> > goto out;
> > }
> > + pr_crit("LIST_FUNC -> %pf()\n", op->func);
> > op->func(ip, parent_ip, op, regs);
> > }
> > } while_for_each_ftrace_op(op);
> >
> > I do
> > # cd /sys/kernel/debug/tracing/
> > # echo "p:xx SyS_prctl+0x1c" >| kprobe_events
> > # cat ../kprobes/list
> > ffffffff81056c4c k SyS_prctl+0x1c [DISABLED][FTRACE]
> > # echo 1 >| events/kprobes/xx/enable
> > #
> > # perl -e 'syscall 157,-1'
> > # dmesg
> > LIST_FUNC -> kprobe_ftrace_handler()
> >
> > so it is really called by the loop test code.
> >
> > And I guess that after your patches kprobe_ftrace_handler() should be called
> > from the trampoline in this case.
>
> No it wont be. Not until we have Paul McKenney's task_rcu code that
> will return after all tasks have either gone through userspace or a
> schedule. Hmm, maybe on a !CONFIG_PREEMPT it will be OK. Oh, I can have
> that be OK now on !CONFIG_PREEMPT. Maybe I'll do that too.
>
> kprobe ftrace_ops are allocated which sets the FTRACE_OPS_FL_DYNAMIC
> flag. You'll see that flag checked in update_ftrace_function(), and if
> it is set, it forces the ftrace_ops_list_func() to be used.
No? __register_ftrace_function() sets if !core_kernel_data(ops), and
kprobe_ftrace_ops is not dynamic?
> Why?
>
> [...snip..]
Yes, thanks, I understand why, at least to some degree.
> foo()
> [mcount called --> ftrace_caller trampoline]
> ftrace_caller
> load ftrace_ops into parameter
> <interrupt>
> preempt_schedule()
> [new task]
> kfree(kprobe ftrace_ops);
see above.
And to be sure, I compiled your rfc/trampoline kernel which I pulled
yesterday with the same patch and did the same test. __ftrace_ops_list_func()
prints nothing.
So I also added WARN_ON(1) into kprobe_ftrace_handler() to ensure that
it is actually called, and yes, dmesg reports
WARNING: ... kprobe_ftrace_handler+0x38/0x140()
...
Call Trace:
[<ffffffff8136a3eb>] dump_stack+0x5b/0xa8
[<ffffffff810423ec>] warn_slowpath_common+0x8c/0xc0
[<ffffffff8105772c>] ? SyS_prctl+0x1c/0x730
[<ffffffff8104243a>] warn_slowpath_null+0x1a/0x20
[<ffffffff810325c8>] kprobe_ftrace_handler+0x38/0x140
[<ffffffff8137148a>] ? retint_swapgs+0xe/0x13
[<ffffffff81057731>] ? SyS_prctl+0x21/0x730
[<ffffffff81057731>] ? SyS_prctl+0x21/0x730
[<ffffffff8122424e>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[<ffffffff81370912>] ? system_call_fastpath+0x16/0x1b
after "perl -e 'syscall 157,-1'".
and, as expected, if I do "echo SyS_prctl >| set_ftrace_filter" and
"echo function >| current_tracer", then the command above also triggers
2 printk's in __ftrace_ops_list_func() :
LIST_FUNC -> function_trace_call()
LIST_FUNC -> kprobe_ftrace_handler()
so it seems that your patches can potentially buy more than you think ;)
Oleg.
next prev parent reply other threads:[~2014-07-23 17:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 20:07 [RFC][PATCH 0/3] ftrace: Add dynamically allocated trampolines Steven Rostedt
2014-07-03 20:07 ` [RFC][PATCH 1/3] ftrace/x86: Add dynamic allocated trampoline for ftrace_ops Steven Rostedt
2014-07-04 13:32 ` Masami Hiramatsu
2014-07-04 14:25 ` Steven Rostedt
2014-07-14 2:34 ` Masami Hiramatsu
2014-07-03 20:07 ` [RFC][PATCH 2/3] ftrace/x86: Show trampoline call function in enabled_functions Steven Rostedt
2014-07-03 20:07 ` [RFC][PATCH 3/3] ftrace/x86: Allow !CONFIG_PREEMPT dynamic ops to use allocated trampolines Steven Rostedt
2014-07-03 20:32 ` [RFC][PATCH 0/3] ftrace: Add dynamically " Steven Rostedt
2014-07-04 13:20 ` Masami Hiramatsu
2014-07-04 14:21 ` Steven Rostedt
2014-07-07 13:22 ` Jiri Kosina
2014-07-08 14:24 ` Steven Rostedt
2014-07-07 13:58 ` Jiri Kosina
2014-07-10 21:36 ` Josh Poimboeuf
2014-07-10 21:44 ` Jiri Kosina
2014-07-10 22:01 ` Josh Poimboeuf
2014-07-11 2:26 ` Masami Hiramatsu
2014-07-11 13:24 ` Jiri Kosina
2014-07-11 14:29 ` Josh Poimboeuf
2014-07-14 1:35 ` Masami Hiramatsu
2014-07-14 7:16 ` Namhyung Kim
2014-07-14 8:18 ` Masami Hiramatsu
2014-07-14 14:18 ` Namhyung Kim
2014-07-15 1:20 ` Masami Hiramatsu
2014-07-22 16:47 ` Oleg Nesterov
2014-07-22 19:02 ` Steven Rostedt
2014-07-23 12:08 ` Oleg Nesterov
2014-07-23 15:48 ` Steven Rostedt
2014-07-23 17:05 ` Oleg Nesterov [this message]
2014-07-23 17:20 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140723170552.GA7820@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=sjenning@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox