Commit 8a56d77
committed
ftrace: Fix function graph with loading of modules
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")
Cc: stable@vger.kernel.org # 3.0+
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>1 parent 4e58e54 commit 8a56d77
1 file changed
+35
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | 370 | | |
374 | 371 | | |
375 | 372 | | |
| |||
428 | 425 | | |
429 | 426 | | |
430 | 427 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | 428 | | |
435 | 429 | | |
436 | 430 | | |
| |||
2088 | 2082 | | |
2089 | 2083 | | |
2090 | 2084 | | |
| 2085 | + | |
2091 | 2086 | | |
2092 | 2087 | | |
2093 | 2088 | | |
2094 | 2089 | | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
2095 | 2094 | | |
2096 | 2095 | | |
2097 | 2096 | | |
| |||
2113 | 2112 | | |
2114 | 2113 | | |
2115 | 2114 | | |
2116 | | - | |
| 2115 | + | |
2117 | 2116 | | |
2118 | 2117 | | |
| 2118 | + | |
2119 | 2119 | | |
2120 | 2120 | | |
2121 | | - | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
2122 | 2126 | | |
2123 | 2127 | | |
2124 | 2128 | | |
| |||
2153 | 2157 | | |
2154 | 2158 | | |
2155 | 2159 | | |
2156 | | - | |
| 2160 | + | |
2157 | 2161 | | |
2158 | 2162 | | |
| 2163 | + | |
2159 | 2164 | | |
2160 | 2165 | | |
2161 | 2166 | | |
| |||
3060 | 3065 | | |
3061 | 3066 | | |
3062 | 3067 | | |
3063 | | - | |
3064 | | - | |
3065 | | - | |
| 3068 | + | |
3066 | 3069 | | |
3067 | 3070 | | |
3068 | 3071 | | |
3069 | 3072 | | |
3070 | 3073 | | |
3071 | 3074 | | |
3072 | | - | |
3073 | 3075 | | |
3074 | 3076 | | |
3075 | 3077 | | |
| |||
3082 | 3084 | | |
3083 | 3085 | | |
3084 | 3086 | | |
3085 | | - | |
3086 | | - | |
3087 | | - | |
| 3087 | + | |
3088 | 3088 | | |
3089 | 3089 | | |
3090 | 3090 | | |
| |||
4366 | 4366 | | |
4367 | 4367 | | |
4368 | 4368 | | |
4369 | | - | |
4370 | | - | |
4371 | | - | |
4372 | | - | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
4373 | 4375 | | |
4374 | | - | |
| 4376 | + | |
| 4377 | + | |
4375 | 4378 | | |
4376 | 4379 | | |
4377 | 4380 | | |
| |||
4780 | 4783 | | |
4781 | 4784 | | |
4782 | 4785 | | |
4783 | | - | |
4784 | | - | |
4785 | | - | |
| 4786 | + | |
4786 | 4787 | | |
4787 | 4788 | | |
4788 | 4789 | | |
| |||
4801 | 4802 | | |
4802 | 4803 | | |
4803 | 4804 | | |
4804 | | - | |
4805 | | - | |
4806 | | - | |
| 4805 | + | |
4807 | 4806 | | |
4808 | 4807 | | |
4809 | 4808 | | |
| |||
4997 | 4996 | | |
4998 | 4997 | | |
4999 | 4998 | | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
5000 | 5006 | | |
5001 | 5007 | | |
5002 | 5008 | | |
| |||
5023 | 5029 | | |
5024 | 5030 | | |
5025 | 5031 | | |
5026 | | - | |
| 5032 | + | |
5027 | 5033 | | |
5028 | 5034 | | |
5029 | 5035 | | |
| |||
5040 | 5046 | | |
5041 | 5047 | | |
5042 | 5048 | | |
5043 | | - | |
| 5049 | + | |
5044 | 5050 | | |
5045 | 5051 | | |
5046 | 5052 | | |
| |||
0 commit comments