<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace_probe.c, branch v5.15</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=v5.15</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.15'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-08-20T18:18:40Z</updated>
<entry>
<title>tracing: Add a probe that attaches to trace events</title>
<updated>2021-08-20T18:18:40Z</updated>
<author>
<name>Tzvetomir Stoyanov (VMware)</name>
<email>tz.stoyanov@gmail.com</email>
</author>
<published>2021-08-19T15:26:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7491e2c442781a1860181adb5ab472a52075f393'/>
<id>urn:sha1:7491e2c442781a1860181adb5ab472a52075f393</id>
<content type='text'>
A new dynamic event is introduced: event probe. The event is attached
to an existing tracepoint and uses its fields as arguments. The user
can specify custom format string of the new event, select what tracepoint
arguments will be printed and how to print them.
An event probe is created by writing configuration string in
'dynamic_events' ftrace file:
 e[:[SNAME/]ENAME] SYSTEM/EVENT [FETCHARGS]	- Set an event probe
 -:SNAME/ENAME					- Delete an event probe

Where:
 SNAME	- System name, if omitted 'eprobes' is used.
 ENAME	- Name of the new event in SNAME, if omitted the SYSTEM_EVENT is used.
 SYSTEM	- Name of the system, where the tracepoint is defined, mandatory.
 EVENT	- Name of the tracepoint event in SYSTEM, mandatory.
 FETCHARGS - Arguments:
  &lt;name&gt;=$&lt;field&gt;[:TYPE] - Fetch given filed of the tracepoint and print
			   it as given TYPE with given name. Supported
			   types are:
	                    (u8/u16/u32/u64/s8/s16/s32/s64), basic type
        	            (x8/x16/x32/x64), hexadecimal types
			    "string", "ustring" and bitfield.

Example, attach an event probe on openat system call and print name of the
file that will be opened:
 echo "e:esys/eopen syscalls/sys_enter_openat file=\$filename:string" &gt;&gt; dynamic_events
A new dynamic event is created in events/esys/eopen/ directory. It
can be deleted with:
 echo "-:esys/eopen" &gt;&gt; dynamic_events

Filters, triggers and histograms can be attached to the new event, it can
be matched in synthetic events. There is one limitation - an event probe
can not be attached to kprobe, uprobe or another event probe.

Link: https://lkml.kernel.org/r/20210812145805.2292326-1-tz.stoyanov@gmail.com
Link: https://lkml.kernel.org/r/20210819152825.142428383@goodmis.org

Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Co-developed-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Tzvetomir Stoyanov (VMware) &lt;tz.stoyanov@gmail.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probes: Reject events which have the same name of existing one</title>
<updated>2021-08-19T13:15:19Z</updated>
<author>
<name>Masami Hiramatsu</name>
<email>mhiramat@kernel.org</email>
</author>
<published>2021-08-19T10:26:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8e242060c6a4947e8ae7d29794af6a581db08841'/>
<id>urn:sha1:8e242060c6a4947e8ae7d29794af6a581db08841</id>
<content type='text'>
Since kprobe_events and uprobe_events only check whether the
other same-type probe event has the same name or not, if the
user gives the same name of the existing tracepoint event (or
the other type of probe events), it silently fails to create
the tracefs entry (but registered.) as below.

/sys/kernel/tracing # ls events/task/task_rename
enable   filter   format   hist     id       trigger
/sys/kernel/tracing # echo p:task/task_rename vfs_read &gt;&gt; kprobe_events
[  113.048508] Could not create tracefs 'task_rename' directory
/sys/kernel/tracing # cat kprobe_events
p:task/task_rename vfs_read

To fix this issue, check whether the existing events have the
same name or not in trace_probe_register_event_call(). If exists,
it rejects to register the new event.

Link: https://lkml.kernel.org/r/162936876189.187130.17558311387542061930.stgit@devnote2

Signed-off-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probe: Change traceprobe_set_print_fmt() to take a type</title>
<updated>2021-08-19T13:08:29Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-08-19T04:13:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=007517a01995fb24f2f4effc9cf34814361a9d10'/>
<id>urn:sha1:007517a01995fb24f2f4effc9cf34814361a9d10</id>
<content type='text'>
Instead of a boolean "is_return" have traceprobe_set_print_fmt() take a
type (currently just PROBE_PRINT_NORMAL and PROBE_PRINT_RETURN). This will
simplify adding different types. For example, the development of the
event_probe, will need its own type as it prints an event, and not an IP.

Link: https://lkml.kernel.org/r/20210819041842.104626301@goodmis.org

Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probes: Allow for dot delimiter as well as slash for system names</title>
<updated>2021-08-18T22:13:52Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-08-17T03:42:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bc1b973455fd5d84dac4a094da44202f2d8a98ef'/>
<id>urn:sha1:bc1b973455fd5d84dac4a094da44202f2d8a98ef</id>
<content type='text'>
Kprobe and uprobe events can add a "system" to the events that are created
via the kprobe_events and uprobe_events files respectively. If they do not
include a "system" in the name, then the default "kprobes" or "uprobes" is
used. The current notation to specify a system for one of these probe
events is to add a '/' delimiter in the name, where the content before the
'/' will be the system to use, and the content after will be the event
name.

 echo 'p:my_system/my_event' &gt; kprobe_events

But this is inconsistent with the way histogram triggers separate their
system / event names. The histogram triggers use a '.' delimiter, which
can be confusing.

To allow this to be more consistent, as well as keep backward
compatibility, allow the kprobe and uprobe events to denote a system name
with either a '/' or a '.'.

That is:

  echo 'p:my_system/my_event' &gt; kprobe_events

is equivalent to:

  echo 'p:my_system.my_event' &gt; kprobe_events

Link: https://lore.kernel.org/linux-trace-devel/20210813004448.51c7de69ce432d338f4d226b@kernel.org/
Link: https://lkml.kernel.org/r/20210817035027.580493202@goodmis.org

Suggested-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probe: Have traceprobe_parse_probe_arg() take a const arg</title>
<updated>2021-08-18T22:13:52Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-08-17T03:42:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fcd9db51df8e219e3a61b14e9b8c5ee67d39d37c'/>
<id>urn:sha1:fcd9db51df8e219e3a61b14e9b8c5ee67d39d37c</id>
<content type='text'>
The two places that call traceprobe_parse_probe_arg() allocate a temporary
buffer to copy the argv[i] into, because argv[i] is constant and the
traceprobe_parse_probe_arg() will modify it to do the parsing. These two
places allocate this buffer and then free it right after calling this
function, leaving the onus of this allocation to the caller.

As there's about to be a third user of this function that will have to do
the same thing, instead of having the caller allocate the temporary
buffer, simply move that allocation into the traceprobe_parse_probe_arg()
itself, which will simplify the code of the callers.

Link: https://lkml.kernel.org/r/20210817035027.385422828@goodmis.org

Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix various typos in comments</title>
<updated>2021-03-23T18:08:18Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@kernel.org</email>
</author>
<published>2021-03-23T17:49:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f2cc020d7876de7583feb52ec939a32419cf9468'/>
<id>urn:sha1:f2cc020d7876de7583feb52ec939a32419cf9468</id>
<content type='text'>
Fix ~59 single-word typos in the tracing code comments, and fix
the grammar in a handful of places.

Link: https://lore.kernel.org/r/20210322224546.GA1981273@gmail.com
Link: https://lkml.kernel.org/r/20210323174935.GA4176821@gmail.com

Reviewed-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/dynevent: Delegate parsing to create function</title>
<updated>2021-02-09T17:52:15Z</updated>
<author>
<name>Masami Hiramatsu</name>
<email>mhiramat@kernel.org</email>
</author>
<published>2021-02-01T19:48:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d262271d04830e4b5009f4a5cc64934d86b49832'/>
<id>urn:sha1:d262271d04830e4b5009f4a5cc64934d86b49832</id>
<content type='text'>
Delegate command parsing to each create function so that the
command syntax can be customized.

This requires changes to the kprobe/uprobe/synthetic event handling,
which are also included here.

Link: https://lkml.kernel.org/r/e488726f49cbdbc01568618f8680584306c4c79f.1612208610.git.zanussi@kernel.org

Signed-off-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
[ zanussi@kernel.org: added synthetic event modifications ]
Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probe: Fix memleak in fetch_op_data operations</title>
<updated>2020-06-17T01:21:02Z</updated>
<author>
<name>Vamshi K Sthambamkadi</name>
<email>vamshi.k.sthambamkadi@gmail.com</email>
</author>
<published>2020-06-15T14:30:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3aa8fdc37d16735e8891035becf25b3857d3efe0'/>
<id>urn:sha1:3aa8fdc37d16735e8891035becf25b3857d3efe0</id>
<content type='text'>
kmemleak report:
    [&lt;57dcc2ca&gt;] __kmalloc_track_caller+0x139/0x2b0
    [&lt;f1c45d0f&gt;] kstrndup+0x37/0x80
    [&lt;f9761eb0&gt;] parse_probe_arg.isra.7+0x3cc/0x630
    [&lt;055bf2ba&gt;] traceprobe_parse_probe_arg+0x2f5/0x810
    [&lt;655a7766&gt;] trace_kprobe_create+0x2ca/0x950
    [&lt;4fc6a02a&gt;] create_or_delete_trace_kprobe+0xf/0x30
    [&lt;6d1c8a52&gt;] trace_run_command+0x67/0x80
    [&lt;be812cc0&gt;] trace_parse_run_command+0xa7/0x140
    [&lt;aecfe401&gt;] probes_write+0x10/0x20
    [&lt;2027641c&gt;] __vfs_write+0x30/0x1e0
    [&lt;6a4aeee1&gt;] vfs_write+0x96/0x1b0
    [&lt;3517fb7d&gt;] ksys_write+0x53/0xc0
    [&lt;dad91db7&gt;] __ia32_sys_write+0x15/0x20
    [&lt;da347f64&gt;] do_syscall_32_irqs_on+0x3d/0x260
    [&lt;fd0b7e7d&gt;] do_fast_syscall_32+0x39/0xb0
    [&lt;ea5ae810&gt;] entry_SYSENTER_32+0xaf/0x102

Post parse_probe_arg(), the FETCH_OP_DATA operation type is overwritten
to FETCH_OP_ST_STRING, as a result memory is never freed since
traceprobe_free_probe_arg() iterates only over SYMBOL and DATA op types

Setup fetch string operation correctly after fetch_op_data operation.

Link: https://lkml.kernel.org/r/20200615143034.GA1734@cosmos

Cc: stable@vger.kernel.org
Fixes: a42e3c4de964 ("tracing/probe: Add immediate string parameter support")
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Vamshi K Sthambamkadi &lt;vamshi.k.sthambamkadi@gmail.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/probe: reverse arguments to list_add</title>
<updated>2020-05-20T01:10:50Z</updated>
<author>
<name>Julia Lawall</name>
<email>Julia.Lawall@inria.fr</email>
</author>
<published>2020-05-07T19:30:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fc9d276f22330e9322a9c592c71e0571810205f7'/>
<id>urn:sha1:fc9d276f22330e9322a9c592c71e0571810205f7</id>
<content type='text'>
Elsewhere in the file, the function trace_kprobe_has_same_kprobe uses
a trace_probe_event.probes object as the second argument of
list_for_each_entry, ie as a list head, while the list_for_each_entry
iterates over the list fields of the trace_probe structures, making
them the list elements.  So, exchange the arguments on the list_add
call to put the list head in the second argument.

Since both list_head structures were just initialized, this problem
did not cause any loss of information.

Link: https://lkml.kernel.org/r/1588879808-24488-1-git-send-email-Julia.Lawall@inria.fr

Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Julia Lawall &lt;Julia.Lawall@inria.fr&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/kprobes: Have uname use __get_str() in print_fmt</title>
<updated>2020-01-27T15:56:02Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2020-01-24T15:07:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=20279420ae3a8ef4c5d9fedc360a2c37a1dbdf1b'/>
<id>urn:sha1:20279420ae3a8ef4c5d9fedc360a2c37a1dbdf1b</id>
<content type='text'>
Thomas Richter reported:

&gt; Test case 66 'Use vfs_getname probe to get syscall args filenames'
&gt; is broken on s390, but works on x86. The test case fails with:
&gt;
&gt;  [root@m35lp76 perf]# perf test -F 66
&gt;  66: Use vfs_getname probe to get syscall args filenames
&gt;            :Recording open file:
&gt;  [ perf record: Woken up 1 times to write data ]
&gt;  [ perf record: Captured and wrote 0.004 MB /tmp/__perf_test.perf.data.TCdYj\
&gt; 	 (20 samples) ]
&gt;  Looking at perf.data file for vfs_getname records for the file we touched:
&gt;   FAILED!
&gt;   [root@m35lp76 perf]#

The root cause was the print_fmt of the kprobe event that referenced the
"ustring"

&gt; Setting up the kprobe event using perf command:
&gt;
&gt;  # ./perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring"
&gt;
&gt; generates this format file:
&gt;   [root@m35lp76 perf]# cat /sys/kernel/debug/tracing/events/probe/\
&gt; 	  vfs_getname/format
&gt;   name: vfs_getname
&gt;   ID: 1172
&gt;   format:
&gt;     field:unsigned short common_type; offset:0; size:2; signed:0;
&gt;     field:unsigned char common_flags; offset:2; size:1; signed:0;
&gt;     field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
&gt;     field:int common_pid; offset:4; size:4; signed:1;
&gt;
&gt;     field:unsigned long __probe_ip; offset:8; size:8; signed:0;
&gt;     field:__data_loc char[] pathname; offset:16; size:4; signed:1;
&gt;
&gt;     print fmt: "(%lx) pathname=\"%s\"", REC-&gt;__probe_ip, REC-&gt;pathname

Instead of using "__get_str(pathname)" it referenced it directly.

Link: http://lkml.kernel.org/r/20200124100742.4050c15e@gandalf.local.home

Cc: stable@vger.kernel.org
Fixes: 88903c464321 ("tracing/probe: Add ustring type for user-space string")
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Reported-by: Thomas Richter &lt;tmricht@linux.ibm.com&gt;
Tested-by: Thomas Richter &lt;tmricht@linux.ibm.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
