<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/ftrace.c, branch v3.17</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2014-08-23T01:04:35Z</updated>
<entry>
<title>ftrace: Use current addr when converting to nop in __ftrace_replace_code()</title>
<updated>2014-08-23T01:04:35Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-08-18T00:59:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=39b5552cd5090d4c210d278cd2732f493075f033'/>
<id>urn:sha1:39b5552cd5090d4c210d278cd2732f493075f033</id>
<content type='text'>
In __ftrace_replace_code(), when converting the call to a nop in a function
it needs to compare against the "curr" (current) value of the ftrace ops, and
not the "new" one. It currently does not affect x86 which is the only arch
to do the trampolines with function graph tracer, but when other archs that do
depend on this code implement the function graph trampoline, it can crash.

Here's an example when ARM uses the trampolines (in the future):

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 9 at kernel/trace/ftrace.c:1716 ftrace_bug+0x17c/0x1f4()
 Modules linked in: omap_rng rng_core ipv6
 CPU: 0 PID: 9 Comm: migration/0 Not tainted 3.16.0-test-10959-gf0094b28f303-dirty #52
 [&lt;c02188f4&gt;] (unwind_backtrace) from [&lt;c021343c&gt;] (show_stack+0x20/0x24)
 [&lt;c021343c&gt;] (show_stack) from [&lt;c095a674&gt;] (dump_stack+0x78/0x94)
 [&lt;c095a674&gt;] (dump_stack) from [&lt;c02532a0&gt;] (warn_slowpath_common+0x7c/0x9c)
 [&lt;c02532a0&gt;] (warn_slowpath_common) from [&lt;c02532ec&gt;] (warn_slowpath_null+0x2c/0x34)
 [&lt;c02532ec&gt;] (warn_slowpath_null) from [&lt;c02cbac4&gt;] (ftrace_bug+0x17c/0x1f4)
 [&lt;c02cbac4&gt;] (ftrace_bug) from [&lt;c02cc44c&gt;] (ftrace_replace_code+0x80/0x9c)
 [&lt;c02cc44c&gt;] (ftrace_replace_code) from [&lt;c02cc658&gt;] (ftrace_modify_all_code+0xb8/0x164)
 [&lt;c02cc658&gt;] (ftrace_modify_all_code) from [&lt;c02cc718&gt;] (__ftrace_modify_code+0x14/0x1c)
 [&lt;c02cc718&gt;] (__ftrace_modify_code) from [&lt;c02c7244&gt;] (multi_cpu_stop+0xf4/0x134)
 [&lt;c02c7244&gt;] (multi_cpu_stop) from [&lt;c02c6e90&gt;] (cpu_stopper_thread+0x54/0x130)
 [&lt;c02c6e90&gt;] (cpu_stopper_thread) from [&lt;c0271cd4&gt;] (smpboot_thread_fn+0x1ac/0x1bc)
 [&lt;c0271cd4&gt;] (smpboot_thread_fn) from [&lt;c026ddf0&gt;] (kthread+0xe0/0xfc)
 [&lt;c026ddf0&gt;] (kthread) from [&lt;c020f318&gt;] (ret_from_fork+0x14/0x20)
 ---[ end trace dc9ce72c5b617d8f ]---
[   65.047264] ftrace failed to modify [&lt;c0208580&gt;] asm_do_IRQ+0x10/0x1c
[   65.054070]  actual: 85:1b:00:eb

Fixes: 7413af1fb70e7 "ftrace: Make get_ftrace_addr() and get_ftrace_addr_old() global"
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix function_profiler and function tracer together</title>
<updated>2014-08-23T01:04:34Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-08-15T21:18:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5f151b240192a1557119d5375af71efc26825bc8'/>
<id>urn:sha1:5f151b240192a1557119d5375af71efc26825bc8</id>
<content type='text'>
The latest rewrite of ftrace removed the separate ftrace_ops of
the function tracer and the function graph tracer and had them
share the same ftrace_ops. This simplified the accounting by removing
the multiple layers of functions called, where the global_ops func
would call a special list that would iterate over the other ops that
were registered within it (like function and function graph), which
itself was registered to the ftrace ops list of all functions
currently active. If that sounds confusing, the code that implemented
it was also confusing and its removal is a good thing.

The problem with this change was that it assumed that the function
and function graph tracer can never be used at the same time.
This is mostly true, but there is an exception. That is when the
function profiler uses the function graph tracer to profile.
The function profiler can be activated the same time as the function
tracer, and this breaks the assumption and the result is that ftrace
will crash (it detects the error and shuts itself down, it does not
cause a kernel oops).

To solve this issue, a previous change allowed the hash tables
for the functions traced by a ftrace_ops to be a pointer and let
multiple ftrace_ops share the same hash. This allows the function
and function_graph tracer to have separate ftrace_ops, but still
share the hash, which is what is done.

Now the function and function graph tracers have separate ftrace_ops
again, and the function tracer can be run while the function_profile
is active.

Cc: stable@vger.kernel.org # 3.16 (apply after 3.17-rc4 is out)
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix up trampoline accounting with looping on hash ops</title>
<updated>2014-08-22T19:24:12Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-08-21T03:57:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bce0b6c51ac76fc0e763262a6c2a9d05e486f0d8'/>
<id>urn:sha1:bce0b6c51ac76fc0e763262a6c2a9d05e486f0d8</id>
<content type='text'>
Now that a ftrace_hash can be shared by multiple ftrace_ops, they can dec
the rec-&gt;flags by more than once (one per those that share the ftrace_hash).
This means that the tramp_hash may not have a hash item when it was added.

For example, if two ftrace_ops share a hash for a ftrace record, and the
first ops has a trampoline, when it adds itself it will set the rec-&gt;flags
TRAMP flag and increments its nr_trampolines counter. When the second ops
is added, it must clear that tramp flag but also decrement the other ops
that shares its hash. As the update to the function callbacks has not yet
been performed, the other ops will not have the tramp hash set yet and it
can not be used to know to decrement its nr_trampolines.

Luckily, the tramp_hash does not need to be used. As the ftrace_mutex is
held, a ops with a trampoline to a record during an update of another ops
that shares the record will have its func_hash pointing to it. Since a
trampoline can only be set for a record if only one ops is attached to it,
we can just check if the record has a trampoline (the FTRACE_FL_TRAMP flag
is set) and then find the ops that has this record in its hashes.

Also added some output to help debug when things go wrong.

Cc: stable@vger.kernel.org # 3.16+ (apply after 3.17-rc4 is out)
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Update all ftrace_ops for a ftrace_hash_ops update</title>
<updated>2014-08-22T17:21:14Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-08-18T17:21:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=84261912ebee41269004e8a9f3614ba38ef6b206'/>
<id>urn:sha1:84261912ebee41269004e8a9f3614ba38ef6b206</id>
<content type='text'>
When updating what an ftrace_ops traces, if it is registered (that is,
actively tracing), and that ftrace_ops uses the shared global_ops
local_hash, then we need to update all tracers that are active and
also share the global_ops' ftrace_hash_ops.

Cc: stable@vger.kernel.org # 3.16 (apply after 3.17-rc4 is out)
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Allow ftrace_ops to use the hashes from other ops</title>
<updated>2014-08-22T17:18:48Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-08-15T21:23:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=33b7f99cf003ca6c1d31c42b50e1100ad71aaec0'/>
<id>urn:sha1:33b7f99cf003ca6c1d31c42b50e1100ad71aaec0</id>
<content type='text'>
Currently the top level debug file system function tracer shares its
ftrace_ops with the function graph tracer. This was thought to be fine
because the tracers are not used together, as one can only enable
function or function_graph tracer in the current_tracer file.

But that assumption proved to be incorrect. The function profiler
can use the function graph tracer when function tracing is enabled.
Since all function graph users uses the function tracing ftrace_ops
this causes a conflict and when a user enables both function profiling
as well as the function tracer it will crash ftrace and disable it.

The quick solution so far is to move them as separate ftrace_ops like
it was earlier. The problem though is to synchronize the functions that
are traced because both function and function_graph tracer are limited
by the selections made in the set_ftrace_filter and set_ftrace_notrace
files.

To handle this, a new structure is made called ftrace_ops_hash. This
structure will now hold the filter_hash and notrace_hash, and the
ftrace_ops will point to this structure. That will allow two ftrace_ops
to share the same hashes.

Since most ftrace_ops do not share the hashes, and to keep allocation
simple, the ftrace_ops structure will include both a pointer to the
ftrace_ops_hash called func_hash, as well as the structure itself,
called local_hash. When the ops are registered, the func_hash pointer
will be initialized to point to the local_hash within the ftrace_ops
structure. Some of the ftrace internal ftrace_ops will be initialized
statically. This will allow for the function and function_graph tracer
to have separate ops but still share the same hash tables that determine
what functions they trace.

Cc: stable@vger.kernel.org # 3.16 (apply after 3.17-rc4 is out)
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'trace-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace</title>
<updated>2014-08-04T18:50:00Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2014-08-04T18:50:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b8c0aa46b3e86083721b57ed2eec6bd2c29ebfba'/>
<id>urn:sha1:b8c0aa46b3e86083721b57ed2eec6bd2c29ebfba</id>
<content type='text'>
Pull tracing updates from Steven Rostedt:
 "This pull request has a lot of work done.  The main thing is the
  changes to the ftrace function callback infrastructure.  It's
  introducing a way to allow different functions to call directly
  different trampolines instead of all calling the same "mcount" one.

  The only user of this for now is the function graph tracer, which
  always had a different trampoline, but the function tracer trampoline
  was called and did basically nothing, and then the function graph
  tracer trampoline was called.  The difference now, is that the
  function graph tracer trampoline can be called directly if a function
  is only being traced by the function graph trampoline.  If function
  tracing is also happening on the same function, the old way is still
  done.

  The accounting for this takes up more memory when function graph
  tracing is activated, as it needs to keep track of which functions it
  uses.  I have a new way that wont take as much memory, but it's not
  ready yet for this merge window, and will have to wait for the next
  one.

  Another big change was the removal of the ftrace_start/stop() calls
  that were used by the suspend/resume code that stopped function
  tracing when entering into suspend and resume paths.  The stop of
  ftrace was done because there was some function that would crash the
  system if one called smp_processor_id()! The stop/start was a big
  hammer to solve the issue at the time, which was when ftrace was first
  introduced into Linux.  Now ftrace has better infrastructure to debug
  such issues, and I found the problem function and labeled it with
  "notrace" and function tracing can now safely be activated all the way
  down into the guts of suspend and resume

  Other changes include clean ups of uprobe code, clean up of the
  trace_seq() code, and other various small fixes and clean ups to
  ftrace and tracing"

* tag 'trace-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (57 commits)
  ftrace: Add warning if tramp hash does not match nr_trampolines
  ftrace: Fix trampoline hash update check on rec-&gt;flags
  ring-buffer: Use rb_page_size() instead of open coded head_page size
  ftrace: Rename ftrace_ops field from trampolines to nr_trampolines
  tracing: Convert local function_graph functions to static
  ftrace: Do not copy old hash when resetting
  tracing: let user specify tracing_thresh after selecting function_graph
  ring-buffer: Always run per-cpu ring buffer resize with schedule_work_on()
  tracing: Remove function_trace_stop and HAVE_FUNCTION_TRACE_MCOUNT_TEST
  s390/ftrace: remove check of obsolete variable function_trace_stop
  arm64, ftrace: Remove check of obsolete variable function_trace_stop
  Blackfin: ftrace: Remove check of obsolete variable function_trace_stop
  metag: ftrace: Remove check of obsolete variable function_trace_stop
  microblaze: ftrace: Remove check of obsolete variable function_trace_stop
  MIPS: ftrace: Remove check of obsolete variable function_trace_stop
  parisc: ftrace: Remove check of obsolete variable function_trace_stop
  sh: ftrace: Remove check of obsolete variable function_trace_stop
  sparc64,ftrace: Remove check of obsolete variable function_trace_stop
  tile: ftrace: Remove check of obsolete variable function_trace_stop
  ftrace: x86: Remove check of obsolete variable function_trace_stop
  ...
</content>
</entry>
<entry>
<title>ftrace: Add warning if tramp hash does not match nr_trampolines</title>
<updated>2014-07-24T15:26:11Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-07-24T15:26:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dc6f03f26f570104a2bb03f9d1deb588026d7c75'/>
<id>urn:sha1:dc6f03f26f570104a2bb03f9d1deb588026d7c75</id>
<content type='text'>
After adding all the records to the tramp_hash, add a check that makes
sure that the number of records added matches the number of records
expected to match and do a WARN_ON and disable ftrace if they do
not match.

Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix trampoline hash update check on rec-&gt;flags</title>
<updated>2014-07-24T14:06:41Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-07-24T13:56:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2a0343baa4cc0d4e618898f8bdae8136bbb6e1b2'/>
<id>urn:sha1:2a0343baa4cc0d4e618898f8bdae8136bbb6e1b2</id>
<content type='text'>
In the loop of ftrace_save_ops_tramp_hash(), it adds all the recs
to the ops hash if the rec has only one callback attached and the
ops is connected to the rec. It gives a nasty warning and shuts down
ftrace if the rec doesn't have a trampoline set for it. But this
can happen with the following scenario:

  # cd /sys/kernel/debug/tracing
  # echo schedule do_IRQ &gt; set_ftrace_filter
  # mkdir instances/foo
  # echo schedule &gt; instances/foo/set_ftrace_filter
  # echo function_graph &gt; current_function
  # echo function &gt; instances/foo/current_function
  # echo nop &gt; instances/foo/current_function

The above would then trigger the following warning and disable
ftrace:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 3145 at kernel/trace/ftrace.c:2212 ftrace_run_update_code+0xe4/0x15b()
 Modules linked in: ipt_MASQUERADE sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ip [...]
 CPU: 1 PID: 3145 Comm: bash Not tainted 3.16.0-rc3-test+ #136
 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
  0000000000000000 ffffffff81808a88 ffffffff81502130 0000000000000000
  ffffffff81040ca1 ffff880077c08000 ffffffff810bd286 0000000000000001
  ffffffff81a56830 ffff88007a041be0 ffff88007a872d60 00000000000001be
 Call Trace:
  [&lt;ffffffff81502130&gt;] ? dump_stack+0x4a/0x75
  [&lt;ffffffff81040ca1&gt;] ? warn_slowpath_common+0x7e/0x97
  [&lt;ffffffff810bd286&gt;] ? ftrace_run_update_code+0xe4/0x15b
  [&lt;ffffffff810bd286&gt;] ? ftrace_run_update_code+0xe4/0x15b
  [&lt;ffffffff810bda1a&gt;] ? ftrace_shutdown+0x11c/0x16b
  [&lt;ffffffff810bda87&gt;] ? unregister_ftrace_function+0x1e/0x38
  [&lt;ffffffff810cc7e1&gt;] ? function_trace_reset+0x1a/0x28
  [&lt;ffffffff810c924f&gt;] ? tracing_set_tracer+0xc1/0x276
  [&lt;ffffffff810c9477&gt;] ? tracing_set_trace_write+0x73/0x91
  [&lt;ffffffff81132383&gt;] ? __sb_start_write+0x9a/0xcc
  [&lt;ffffffff8120478f&gt;] ? security_file_permission+0x1b/0x31
  [&lt;ffffffff81130e49&gt;] ? vfs_write+0xac/0x11c
  [&lt;ffffffff8113115d&gt;] ? SyS_write+0x60/0x8e
  [&lt;ffffffff81508112&gt;] ? system_call_fastpath+0x16/0x1b
 ---[ end trace 938c4415cbc7dc96 ]---
 ------------[ cut here ]------------

Link: http://lkml.kernel.org/r/20140723120805.GB21376@redhat.com

Reported-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Rename ftrace_ops field from trampolines to nr_trampolines</title>
<updated>2014-07-23T19:03:00Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-07-23T19:03:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0162d621ddf3bd02bf7de324dcf002d9c84c5059'/>
<id>urn:sha1:0162d621ddf3bd02bf7de324dcf002d9c84c5059</id>
<content type='text'>
Having two fields within the same struct that is off by one character
can be confusing and error prone. Rename the counter "trampolines"
to "nr_trampolines" to explicitly show it is a counter and not to
be confused by the "trampoline" field.

Suggested-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Do not copy old hash when resetting</title>
<updated>2014-07-18T21:47:04Z</updated>
<author>
<name>Wang Nan</name>
<email>wangnan0@huawei.com</email>
</author>
<published>2014-07-15T00:40:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b972cc58ced01ba2cf1f67b36bcfbb3ed4fa706e'/>
<id>urn:sha1:b972cc58ced01ba2cf1f67b36bcfbb3ed4fa706e</id>
<content type='text'>
Do not waste time copying the old hash if the hash is going to be
reset. Just allocate a new hash and free the old one, as that is
the same result as copying te old one and then resetting it.

Link: http://lkml.kernel.org/p/1405384820-48837-1-git-send-email-wangnan0@huawei.com

Signed-off-by: Wang Nan &lt;wangnan0@huawei.com&gt;
[ SDR: Removed unused ftrace_filter_reset() function ]
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
