Commit 2940c25
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 hardkernel#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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent ad03714 commit 2940c25
1 file changed
Lines changed: 35 additions & 29 deletions
| 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 | | |
| |||
417 | 414 | | |
418 | 415 | | |
419 | 416 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | 417 | | |
424 | 418 | | |
425 | 419 | | |
| |||
2048 | 2042 | | |
2049 | 2043 | | |
2050 | 2044 | | |
| 2045 | + | |
2051 | 2046 | | |
2052 | 2047 | | |
2053 | 2048 | | |
2054 | 2049 | | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
2055 | 2054 | | |
2056 | 2055 | | |
2057 | 2056 | | |
| |||
2073 | 2072 | | |
2074 | 2073 | | |
2075 | 2074 | | |
2076 | | - | |
| 2075 | + | |
2077 | 2076 | | |
2078 | 2077 | | |
| 2078 | + | |
2079 | 2079 | | |
2080 | 2080 | | |
2081 | | - | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
2082 | 2086 | | |
2083 | 2087 | | |
2084 | 2088 | | |
| |||
2113 | 2117 | | |
2114 | 2118 | | |
2115 | 2119 | | |
2116 | | - | |
| 2120 | + | |
2117 | 2121 | | |
2118 | 2122 | | |
| 2123 | + | |
2119 | 2124 | | |
2120 | 2125 | | |
2121 | 2126 | | |
| |||
3020 | 3025 | | |
3021 | 3026 | | |
3022 | 3027 | | |
3023 | | - | |
3024 | | - | |
3025 | | - | |
| 3028 | + | |
3026 | 3029 | | |
3027 | 3030 | | |
3028 | 3031 | | |
3029 | 3032 | | |
3030 | 3033 | | |
3031 | 3034 | | |
3032 | | - | |
3033 | 3035 | | |
3034 | 3036 | | |
3035 | 3037 | | |
| |||
3042 | 3044 | | |
3043 | 3045 | | |
3044 | 3046 | | |
3045 | | - | |
3046 | | - | |
3047 | | - | |
| 3047 | + | |
3048 | 3048 | | |
3049 | 3049 | | |
3050 | 3050 | | |
| |||
4241 | 4241 | | |
4242 | 4242 | | |
4243 | 4243 | | |
4244 | | - | |
4245 | | - | |
4246 | | - | |
4247 | | - | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
4248 | 4250 | | |
4249 | | - | |
| 4251 | + | |
| 4252 | + | |
4250 | 4253 | | |
4251 | 4254 | | |
4252 | 4255 | | |
| |||
4646 | 4649 | | |
4647 | 4650 | | |
4648 | 4651 | | |
4649 | | - | |
4650 | | - | |
4651 | | - | |
| 4652 | + | |
4652 | 4653 | | |
4653 | 4654 | | |
4654 | 4655 | | |
| |||
4667 | 4668 | | |
4668 | 4669 | | |
4669 | 4670 | | |
4670 | | - | |
4671 | | - | |
4672 | | - | |
| 4671 | + | |
4673 | 4672 | | |
4674 | 4673 | | |
4675 | 4674 | | |
| |||
4863 | 4862 | | |
4864 | 4863 | | |
4865 | 4864 | | |
| 4865 | + | |
| 4866 | + | |
| 4867 | + | |
| 4868 | + | |
| 4869 | + | |
| 4870 | + | |
| 4871 | + | |
4866 | 4872 | | |
4867 | 4873 | | |
4868 | 4874 | | |
| |||
4889 | 4895 | | |
4890 | 4896 | | |
4891 | 4897 | | |
4892 | | - | |
| 4898 | + | |
4893 | 4899 | | |
4894 | 4900 | | |
4895 | 4901 | | |
| |||
4906 | 4912 | | |
4907 | 4913 | | |
4908 | 4914 | | |
4909 | | - | |
| 4915 | + | |
4910 | 4916 | | |
4911 | 4917 | | |
4912 | 4918 | | |
| |||
0 commit comments