Commit 51d351d
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 5833570 commit 51d351d
1 file changed
Lines changed: 34 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 315 | | |
319 | 316 | | |
320 | 317 | | |
| |||
348 | 345 | | |
349 | 346 | | |
350 | 347 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | 348 | | |
355 | 349 | | |
356 | 350 | | |
| |||
1940 | 1934 | | |
1941 | 1935 | | |
1942 | 1936 | | |
| 1937 | + | |
1943 | 1938 | | |
1944 | 1939 | | |
1945 | 1940 | | |
1946 | 1941 | | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1947 | 1946 | | |
1948 | 1947 | | |
1949 | 1948 | | |
| |||
1965 | 1964 | | |
1966 | 1965 | | |
1967 | 1966 | | |
1968 | | - | |
| 1967 | + | |
1969 | 1968 | | |
1970 | 1969 | | |
| 1970 | + | |
1971 | 1971 | | |
1972 | 1972 | | |
1973 | | - | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
1974 | 1978 | | |
1975 | 1979 | | |
1976 | 1980 | | |
| |||
2005 | 2009 | | |
2006 | 2010 | | |
2007 | 2011 | | |
2008 | | - | |
| 2012 | + | |
2009 | 2013 | | |
2010 | 2014 | | |
| 2015 | + | |
2011 | 2016 | | |
2012 | 2017 | | |
2013 | 2018 | | |
| |||
2873 | 2878 | | |
2874 | 2879 | | |
2875 | 2880 | | |
2876 | | - | |
2877 | | - | |
2878 | | - | |
| 2881 | + | |
2879 | 2882 | | |
2880 | 2883 | | |
2881 | 2884 | | |
2882 | 2885 | | |
2883 | 2886 | | |
2884 | 2887 | | |
2885 | | - | |
2886 | 2888 | | |
2887 | 2889 | | |
2888 | 2890 | | |
| |||
2895 | 2897 | | |
2896 | 2898 | | |
2897 | 2899 | | |
2898 | | - | |
2899 | | - | |
2900 | | - | |
| 2900 | + | |
2901 | 2901 | | |
2902 | 2902 | | |
2903 | 2903 | | |
| |||
3948 | 3948 | | |
3949 | 3949 | | |
3950 | 3950 | | |
3951 | | - | |
3952 | | - | |
3953 | | - | |
3954 | | - | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
3955 | 3957 | | |
3956 | | - | |
| 3958 | + | |
| 3959 | + | |
3957 | 3960 | | |
3958 | 3961 | | |
3959 | 3962 | | |
| |||
4323 | 4326 | | |
4324 | 4327 | | |
4325 | 4328 | | |
4326 | | - | |
4327 | | - | |
4328 | | - | |
4329 | | - | |
4330 | | - | |
4331 | | - | |
4332 | | - | |
| 4329 | + | |
4333 | 4330 | | |
4334 | | - | |
4335 | 4331 | | |
4336 | 4332 | | |
4337 | 4333 | | |
| |||
4348 | 4344 | | |
4349 | 4345 | | |
4350 | 4346 | | |
4351 | | - | |
4352 | | - | |
4353 | | - | |
| 4347 | + | |
4354 | 4348 | | |
4355 | 4349 | | |
4356 | 4350 | | |
| |||
4544 | 4538 | | |
4545 | 4539 | | |
4546 | 4540 | | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
4547 | 4547 | | |
4548 | 4548 | | |
4549 | 4549 | | |
| |||
4570 | 4570 | | |
4571 | 4571 | | |
4572 | 4572 | | |
4573 | | - | |
| 4573 | + | |
4574 | 4574 | | |
4575 | 4575 | | |
4576 | 4576 | | |
| |||
4587 | 4587 | | |
4588 | 4588 | | |
4589 | 4589 | | |
4590 | | - | |
| 4590 | + | |
4591 | 4591 | | |
4592 | 4592 | | |
4593 | 4593 | | |
| |||
0 commit comments