Commit 7c4f6a4
ftrace: Fix function graph with loading of modules
commit 8a56d77 upstream.
Commit 8c4f3c3 "ftrace: Check module functions being traced on reload"
fixed module loading and unloading with respect to function tracing, but
it missed the function graph tracer. If you perform the following
# cd /sys/kernel/debug/tracing
# echo function_graph > current_tracer
# modprobe nfsd
# echo nop > current_tracer
You'll get the following oops message:
------------[ cut here ]------------
WARNING: CPU: 2 PID: 2910 at /linux.git/kernel/trace/ftrace.c:1640 __ftrace_hash_rec_update.part.35+0x168/0x1b9()
Modules linked in: nfsd exportfs nfs_acl lockd ipt_MASQUERADE sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 ip6table_filter ip6_tables uinput snd_hda_codec_idt
CPU: 2 PID: 2910 Comm: bash Not tainted 3.13.0-rc1-test #7
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS SDBLI944.86P 05/08/2007
0000000000000668 ffff8800787efcf8 ffffffff814fe193 ffff88007d500000
0000000000000000 ffff8800787efd38 ffffffff8103b80a 0000000000000668
ffffffff810b2b9a ffffffff81a48370 0000000000000001 ffff880037aea000
Call Trace:
[<ffffffff814fe193>] dump_stack+0x4f/0x7c
[<ffffffff8103b80a>] warn_slowpath_common+0x81/0x9b
[<ffffffff810b2b9a>] ? __ftrace_hash_rec_update.part.35+0x168/0x1b9
[<ffffffff8103b83e>] warn_slowpath_null+0x1a/0x1c
[<ffffffff810b2b9a>] __ftrace_hash_rec_update.part.35+0x168/0x1b9
[<ffffffff81502f89>] ? __mutex_lock_slowpath+0x364/0x364
[<ffffffff810b2cc2>] ftrace_shutdown+0xd7/0x12b
[<ffffffff810b47f0>] unregister_ftrace_graph+0x49/0x78
[<ffffffff810c4b30>] graph_trace_reset+0xe/0x10
[<ffffffff810bf393>] tracing_set_tracer+0xa7/0x26a
[<ffffffff810bf5e1>] tracing_set_trace_write+0x8b/0xbd
[<ffffffff810c501c>] ? ftrace_return_to_handler+0xb2/0xde
[<ffffffff811240a8>] ? __sb_end_write+0x5e/0x5e
[<ffffffff81122aed>] vfs_write+0xab/0xf6
[<ffffffff8150a185>] ftrace_graph_caller+0x85/0x85
[<ffffffff81122dbd>] SyS_write+0x59/0x82
[<ffffffff8150a185>] ftrace_graph_caller+0x85/0x85
[<ffffffff8150a2d2>] system_call_fastpath+0x16/0x1b
---[ end trace 940358030751eafb ]---
The above mentioned commit didn't go far enough. Well, it covered the
function tracer by adding checks in __register_ftrace_function(). The
problem is that the function graph tracer circumvents that (for a slight
efficiency gain when function graph trace is running with a function
tracer. The gain was not worth this).
The problem came with ftrace_startup() which should always be called after
__register_ftrace_function(), if you want this bug to be completely fixed.
Anyway, this solution moves __register_ftrace_function() inside of
ftrace_startup() and removes the need to call them both.
Reported-by: Dave Wysochanski <dwysocha@redhat.com>
Fixes: ed926f9 ("ftrace: Use counters to enable functions to trace")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
[ kamal: backport to 3.8 (no FTRACE_OPS_FL_STUB); prereq for a4c35ed
"ftrace: Fix synchronization location disabling and freeing ftrace_ops" ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>1 parent 14c8fea commit 7c4f6a4
1 file changed
Lines changed: 35 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | 327 | | |
331 | 328 | | |
332 | 329 | | |
| |||
374 | 371 | | |
375 | 372 | | |
376 | 373 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | 374 | | |
381 | 375 | | |
382 | 376 | | |
| |||
2009 | 2003 | | |
2010 | 2004 | | |
2011 | 2005 | | |
| 2006 | + | |
2012 | 2007 | | |
2013 | 2008 | | |
2014 | 2009 | | |
2015 | 2010 | | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
2016 | 2015 | | |
2017 | 2016 | | |
2018 | 2017 | | |
| |||
2034 | 2033 | | |
2035 | 2034 | | |
2036 | 2035 | | |
2037 | | - | |
| 2036 | + | |
2038 | 2037 | | |
2039 | 2038 | | |
| 2039 | + | |
2040 | 2040 | | |
2041 | 2041 | | |
2042 | | - | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
2043 | 2047 | | |
2044 | 2048 | | |
2045 | 2049 | | |
| |||
2074 | 2078 | | |
2075 | 2079 | | |
2076 | 2080 | | |
2077 | | - | |
| 2081 | + | |
2078 | 2082 | | |
2079 | 2083 | | |
| 2084 | + | |
2080 | 2085 | | |
2081 | 2086 | | |
2082 | 2087 | | |
| |||
2974 | 2979 | | |
2975 | 2980 | | |
2976 | 2981 | | |
2977 | | - | |
2978 | | - | |
2979 | | - | |
| 2982 | + | |
2980 | 2983 | | |
2981 | 2984 | | |
2982 | 2985 | | |
2983 | 2986 | | |
2984 | 2987 | | |
2985 | 2988 | | |
2986 | | - | |
2987 | 2989 | | |
2988 | 2990 | | |
2989 | 2991 | | |
| |||
2996 | 2998 | | |
2997 | 2999 | | |
2998 | 3000 | | |
2999 | | - | |
3000 | | - | |
3001 | | - | |
| 3001 | + | |
3002 | 3002 | | |
3003 | 3003 | | |
3004 | 3004 | | |
| |||
4131 | 4131 | | |
4132 | 4132 | | |
4133 | 4133 | | |
4134 | | - | |
4135 | | - | |
4136 | | - | |
4137 | | - | |
| 4134 | + | |
| 4135 | + | |
| 4136 | + | |
| 4137 | + | |
| 4138 | + | |
| 4139 | + | |
4138 | 4140 | | |
4139 | | - | |
| 4141 | + | |
| 4142 | + | |
4140 | 4143 | | |
4141 | 4144 | | |
4142 | 4145 | | |
| |||
4536 | 4539 | | |
4537 | 4540 | | |
4538 | 4541 | | |
4539 | | - | |
4540 | | - | |
4541 | | - | |
| 4542 | + | |
4542 | 4543 | | |
4543 | 4544 | | |
4544 | 4545 | | |
| |||
4557 | 4558 | | |
4558 | 4559 | | |
4559 | 4560 | | |
4560 | | - | |
4561 | | - | |
4562 | | - | |
| 4561 | + | |
4563 | 4562 | | |
4564 | 4563 | | |
4565 | 4564 | | |
| |||
4753 | 4752 | | |
4754 | 4753 | | |
4755 | 4754 | | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
4756 | 4762 | | |
4757 | 4763 | | |
4758 | 4764 | | |
| |||
4779 | 4785 | | |
4780 | 4786 | | |
4781 | 4787 | | |
4782 | | - | |
| 4788 | + | |
4783 | 4789 | | |
4784 | 4790 | | |
4785 | 4791 | | |
| |||
4796 | 4802 | | |
4797 | 4803 | | |
4798 | 4804 | | |
4799 | | - | |
| 4805 | + | |
4800 | 4806 | | |
4801 | 4807 | | |
4802 | 4808 | | |
| |||
0 commit comments