<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/ftrace.c, branch v3.19</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.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2015-01-15T14:37:33Z</updated>
<entry>
<title>ftrace: Check both notrace and filter for old hash</title>
<updated>2015-01-15T14:37:33Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2015-01-13T19:03:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7485058eea40783ac142a60c3e799fc66ce72583'/>
<id>urn:sha1:7485058eea40783ac142a60c3e799fc66ce72583</id>
<content type='text'>
Using just the filter for checking for trampolines or regs is not enough
when updating the code against the records that represent all functions.
Both the filter hash and the notrace hash need to be checked.

To trigger this bug (using trace-cmd and perf):

 # perf probe -a do_fork
 # trace-cmd start -B foo -e probe
 # trace-cmd record -p function_graph -n do_fork sleep 1

The trace-cmd record at the end clears the filter before it disables
function_graph tracing and then that causes the accounting of the
ftrace function records to become incorrect and causes ftrace to bug.

Link: http://lkml.kernel.org/r/20150114154329.358378039@goodmis.org

Cc: stable@vger.kernel.org
[ still need to switch old_hash_ops to old_ops_hash ]
Reviewed-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix updating of filters for shared global_ops filters</title>
<updated>2015-01-15T14:37:07Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2015-01-13T16:20:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8f86f83709c585742dea5dd7f0d2b79c43f992ec'/>
<id>urn:sha1:8f86f83709c585742dea5dd7f0d2b79c43f992ec</id>
<content type='text'>
As the set_ftrace_filter affects both the function tracer as well as the
function graph tracer, the ops that represent each have a shared
ftrace_ops_hash structure. This allows both to be updated when the filter
files are updated.

But if function graph is enabled and the global_ops (function tracing) ops
is not, then it is possible that the filter could be changed without the
update happening for the function graph ops. This will cause the changes
to not take place and may even cause a ftrace_bug to occur as it could mess
with the trampoline accounting.

The solution is to check if the ops uses the shared global_ops filter and
if the ops itself is not enabled, to check if there's another ops that is
enabled and also shares the global_ops filter. In that case, the
modification still needs to be executed.

Link: http://lkml.kernel.org/r/20150114154329.055980438@goodmis.org

Cc: stable@vger.kernel.org # 3.17+
Reviewed-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict</title>
<updated>2014-11-21T19:42:10Z</updated>
<author>
<name>Masami Hiramatsu</name>
<email>masami.hiramatsu.pt@hitachi.com</email>
</author>
<published>2014-11-21T10:25:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f8b8be8a310a55856fd2c369dade08088d85df3b'/>
<id>urn:sha1:f8b8be8a310a55856fd2c369dade08088d85df3b</id>
<content type='text'>
Introduce FTRACE_OPS_FL_IPMODIFY to avoid conflict among
ftrace users who may modify regs-&gt;ip to change the execution
path. If two or more users modify the regs-&gt;ip on the same
function entry, one of them will be broken. So they must add
IPMODIFY flag and make sure that ftrace_set_filter_ip() succeeds.

Note that ftrace doesn't allow ftrace_ops which has IPMODIFY
flag to have notrace hash, and the ftrace_ops must have a
filter hash (so that the ftrace_ops can hook only specific
entries), because it strongly depends on the address and
must be allowed for only few selected functions.

Link: http://lkml.kernel.org/r/20141121102516.11844.27829.stgit@localhost.localdomain

Cc: Jiri Kosina &lt;jkosina@suse.cz&gt;
Cc: Seth Jennings &lt;sjenning@redhat.com&gt;
Cc: Petr Mladek &lt;pmladek@suse.cz&gt;
Cc: Vojtech Pavlik &lt;vojtech@suse.cz&gt;
Cc: Miroslav Benes &lt;mbenes@suse.cz&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;
Cc: Josh Poimboeuf &lt;jpoimboe@redhat.com&gt;
Cc: Namhyung Kim &lt;namhyung@kernel.org&gt;
Signed-off-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
[ fixed up some of the comments ]
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/trivial: Fix typos and make an int into a bool</title>
<updated>2014-11-20T15:05:36Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-11-20T15:05:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0af26492d5f5c00a08d52e9f3f3831faead90246'/>
<id>urn:sha1:0af26492d5f5c00a08d52e9f3f3831faead90246</id>
<content type='text'>
Fix up a few typos in comments and convert an int into a bool in
update_traceon_count().

Link: http://lkml.kernel.org/r/546DD445.5080108@hitachi.com

Suggested-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace/x86/extable: Add is_ftrace_trampoline() function</title>
<updated>2014-11-19T20:25:26Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-11-19T02:14:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=aec0be2d6e9f02dbef41ee54854c2e003e55c23e'/>
<id>urn:sha1:aec0be2d6e9f02dbef41ee54854c2e003e55c23e</id>
<content type='text'>
Stack traces that happen from function tracing check if the address
on the stack is a __kernel_text_address(). That is, is the address
kernel code. This calls core_kernel_text() which returns true
if the address is part of the builtin kernel code. It also calls
is_module_text_address() which returns true if the address belongs
to module code.

But what is missing is ftrace dynamically allocated trampolines.
These trampolines are allocated for individual ftrace_ops that
call the ftrace_ops callback functions directly. But if they do a
stack trace, the code checking the stack wont detect them as they
are neither core kernel code nor module address space.

Adding another field to ftrace_ops that also stores the size of
the trampoline assigned to it we can create a new function called
is_ftrace_trampoline() that returns true if the address is a
dynamically allocate ftrace trampoline. Note, it ignores trampolines
that are not dynamically allocated as they will return true with
the core_kernel_text() function.

Link: http://lkml.kernel.org/r/20141119034829.497125839@goodmis.org

Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Acked-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Replace seq_printf by simpler equivalents</title>
<updated>2014-11-14T02:32:19Z</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2014-11-08T20:42:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fa6f0cc751d377af3f4f1484bceb47dc10163753'/>
<id>urn:sha1:fa6f0cc751d377af3f4f1484bceb47dc10163753</id>
<content type='text'>
Using seq_printf to print a simple string or a single character is a
lot more expensive than it needs to be, since seq_puts and seq_putc
exist.

These patches do

  seq_printf(m, s) -&gt; seq_puts(m, s)
  seq_printf(m, "%s", s) -&gt; seq_puts(m, s)
  seq_printf(m, "%c", c) -&gt; seq_putc(m, c)

Subsequent patches will simplify further.

Link: http://lkml.kernel.org/r/1415479332-25944-2-git-send-email-linux@rasmusvillemoes.dk

Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Have the control_ops get a trampoline</title>
<updated>2014-11-14T00:40:56Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-11-14T00:40:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fe578ba36fe7a118298028031b3ce562e6ea1c4c'/>
<id>urn:sha1:fe578ba36fe7a118298028031b3ce562e6ea1c4c</id>
<content type='text'>
With the new logic, if only a single user of ftrace function hooks is
used, it will get its own trampoline assigned to it.

The problem is that the control_ops is an indirect ops that perf ops
uses. What that means is that when perf registers its ops with
register_ftrace_function(), it has the CONTROL flag set and gets added
to the control list instead of the global ftrace list. The control_ops
gets added to that instead and the mcount trampoline calls the control_ops
function. The control_ops function will iterate the control list and
call the ops functions that are attached to it.

But currently the trampoline is added to the perf ops and not the
control ops, and when ftrace tries to find a trampoline hook for it,
it fails to find one and gives the following splat:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 10133 at kernel/trace/ftrace.c:2033 ftrace_get_addr_new+0x6f/0xc0()
 Modules linked in: [...]
 CPU: 0 PID: 10133 Comm: perf Tainted: P               3.18.0-rc1-test+ #388
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v02.05 05/07/2012
  00000000000007f1 ffff8800c2643bc8 ffffffff814fca6e ffff88011ea0ed01
  0000000000000000 ffff8800c2643c08 ffffffff81041ffd 0000000000000000
  ffffffff810c388c ffffffff81a5a350 ffff880119b00000 ffffffff810001c8
 Call Trace:
  [&lt;ffffffff814fca6e&gt;] dump_stack+0x46/0x58
  [&lt;ffffffff81041ffd&gt;] warn_slowpath_common+0x81/0x9b
  [&lt;ffffffff810c388c&gt;] ? ftrace_get_addr_new+0x6f/0xc0
  [&lt;ffffffff810001c8&gt;] ? 0xffffffff810001c8
  [&lt;ffffffff81042031&gt;] warn_slowpath_null+0x1a/0x1c
  [&lt;ffffffff810c388c&gt;] ftrace_get_addr_new+0x6f/0xc0
  [&lt;ffffffff8102e938&gt;] ftrace_replace_code+0xd6/0x334
  [&lt;ffffffff810c4116&gt;] ftrace_modify_all_code+0x41/0xc5
  [&lt;ffffffff8102eba6&gt;] arch_ftrace_update_code+0x10/0x19
  [&lt;ffffffff810c293c&gt;] ftrace_run_update_code+0x21/0x42
  [&lt;ffffffff810c298f&gt;] ftrace_startup_enable+0x32/0x34
  [&lt;ffffffff810c3049&gt;] ftrace_startup+0x14e/0x15a
  [&lt;ffffffff810c307c&gt;] register_ftrace_function+0x27/0x40
  [&lt;ffffffff810dc118&gt;] perf_ftrace_event_register+0x3e/0xee
  [&lt;ffffffff810dbfbe&gt;] perf_trace_init+0x29d/0x2a9
  [&lt;ffffffff810eb422&gt;] perf_tp_event_init+0x27/0x3a
  [&lt;ffffffff810f18bc&gt;] perf_init_event+0x9e/0xed
  [&lt;ffffffff810f1ba4&gt;] perf_event_alloc+0x299/0x330
  [&lt;ffffffff810f236b&gt;] SYSC_perf_event_open+0x3ee/0x816
  [&lt;ffffffff8115a066&gt;] ? mntput+0x2d/0x2f
  [&lt;ffffffff81142b00&gt;] ? __fput+0xa7/0x1b2
  [&lt;ffffffff81091300&gt;] ? do_gettimeofday+0x22/0x3a
  [&lt;ffffffff810f279c&gt;] SyS_perf_event_open+0x9/0xb
  [&lt;ffffffff81502a92&gt;] system_call_fastpath+0x12/0x17
 ---[ end trace 81a53565150e4982 ]---
 Bad trampoline accounting at: ffffffff810001c8 (run_init_process+0x0/0x2d) (10000001)

Update the control_ops trampoline instead of the perf ops one.

Reported-by: lkp@01.org
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Add more information to ftrace_bug() output</title>
<updated>2014-11-11T17:42:13Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-10-24T21:56:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4fd3279b48605ae3ea509b9b2c02e46aa0975930'/>
<id>urn:sha1:4fd3279b48605ae3ea509b9b2c02e46aa0975930</id>
<content type='text'>
With the introduction of the dynamic trampolines, it is useful that if
things go wrong that ftrace_bug() produces more information about what
the current state is. This can help debug issues that may arise.

Ftrace has lots of checks to make sure that the state of the system it
touchs is exactly what it expects it to be. When it detects an abnormality
it calls ftrace_bug() and disables itself to prevent any further damage.
It is crucial that ftrace_bug() produces sufficient information that
can be used to debug the situation.

Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Acked-by: Borislav Petkov &lt;bp@suse.de&gt;
Tested-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Tested-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace/x86: Allow !CONFIG_PREEMPT dynamic ops to use allocated trampolines</title>
<updated>2014-11-11T17:41:52Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-07-03T19:48:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=12cce594fa8f12e002e7eb5d10141853c1e6a112'/>
<id>urn:sha1:12cce594fa8f12e002e7eb5d10141853c1e6a112</id>
<content type='text'>
When the static ftrace_ops (like function tracer) enables tracing, and it
is the only callback that is referencing a function, a trampoline is
dynamically allocated to the function that calls the callback directly
instead of calling a loop function that iterates over all the registered
ftrace ops (if more than one ops is registered).

But when it comes to dynamically allocated ftrace_ops, where they may be
freed, on a CONFIG_PREEMPT kernel there's no way to know when it is safe
to free the trampoline. If a task was preempted while executing on the
trampoline, there's currently no way to know when it will be off that
trampoline.

But this is not true when it comes to !CONFIG_PREEMPT. The current method
of calling schedule_on_each_cpu() will force tasks off the trampoline,
becaues they can not schedule while on it (kernel preemption is not
configured). That means it is safe to free a dynamically allocated
ftrace ops trampoline when CONFIG_PREEMPT is not configured.

Cc: H. Peter Anvin &lt;hpa@linux.intel.com&gt;
Cc: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Acked-by: Borislav Petkov &lt;bp@suse.de&gt;
Tested-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Tested-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace/x86: Show trampoline call function in enabled_functions</title>
<updated>2014-10-31T16:22:54Z</updated>
<author>
<name>Steven Rostedt (Red Hat)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-07-03T18:51:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=15d5b02cc575e5b20ddfa1645fc1242f0b0ba1c8'/>
<id>urn:sha1:15d5b02cc575e5b20ddfa1645fc1242f0b0ba1c8</id>
<content type='text'>
The file /sys/kernel/debug/tracing/eneabled_functions is used to debug
ftrace function hooks. Add to the output what function is being called
by the trampoline if the arch supports it.

Add support for this feature in x86_64.

Cc: H. Peter Anvin &lt;hpa@linux.intel.com&gt;
Tested-by: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Tested-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
