<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace_eprobe.c, branch v5.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=v5.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2022-02-25T17:07:01Z</updated>
<entry>
<title>eprobes: Remove redundant event type information</title>
<updated>2022-02-25T17:07:01Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-02-19T00:00:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b61edd57740de5895f44f2ea417b164d9e1708bb'/>
<id>urn:sha1:b61edd57740de5895f44f2ea417b164d9e1708bb</id>
<content type='text'>
Currently, the event probes save the type of the event they are attached
to when recording the event. For example:

  # echo 'e:switch sched/sched_switch prev_state=$prev_state prev_prio=$prev_prio next_pid=$next_pid next_prio=$next_prio' &gt; dynamic_events
  # cat events/eprobes/switch/format

 name: switch
 ID: 1717
 format:
        field:unsigned short common_type;       offset:0;       size:2; signed:0;
        field:unsigned char common_flags;       offset:2;       size:1; signed:0;
        field:unsigned char common_preempt_count;       offset:3;       size:1; signed:0;
        field:int common_pid;   offset:4;       size:4; signed:1;

        field:unsigned int __probe_type;        offset:8;       size:4; signed:0;
        field:u64 prev_state;   offset:12;      size:8; signed:0;
        field:u64 prev_prio;    offset:20;      size:8; signed:0;
        field:u64 next_pid;     offset:28;      size:8; signed:0;
        field:u64 next_prio;    offset:36;      size:8; signed:0;

 print fmt: "(%u) prev_state=0x%Lx prev_prio=0x%Lx next_pid=0x%Lx next_prio=0x%Lx", REC-&gt;__probe_type, REC-&gt;prev_state, REC-&gt;prev_prio, REC-&gt;next_pid, REC-&gt;next_prio

The __probe_type adds 4 bytes to every event.

One of the reasons for creating eprobes is to limit what is traced in an
event to be able to limit what is written into the ring buffer. Having
this redundant 4 bytes to every event takes away from this.

The event that is recorded can be retrieved from the event probe itself,
that is available when the trace is happening. For user space tools, it
could simply read the dynamic_event file to find the event they are for.
So there is really no reason to write this information into the ring
buffer for every event.

Link: https://lkml.kernel.org/r/20220218190057.2f5a19a8@gandalf.local.home

Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Reviewed-by: Joel Fernandes &lt;joel@joelfernandes.org&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Remove ops param from event_command reg()/unreg() callbacks</title>
<updated>2022-01-10T16:09:11Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2022-01-10T14:04:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2378a2d6b6cf863bdd566aae495336c72bdaec99'/>
<id>urn:sha1:2378a2d6b6cf863bdd566aae495336c72bdaec99</id>
<content type='text'>
The event_trigger_ops for an event_command are already accessible via
event_trigger_data.ops so remove the redundant ops from the callback.

Link: https://lkml.kernel.org/r/4c6f2a41820452f9cacddc7634ad442928aa2aa6.1641823001.git.zanussi@kernel.org

Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Change event_trigger_ops func() to trigger()</title>
<updated>2022-01-10T16:09:10Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2022-01-10T14:04:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fb339e531bfccbd12d49b165f37636e62778b69f'/>
<id>urn:sha1:fb339e531bfccbd12d49b165f37636e62778b69f</id>
<content type='text'>
The name of the func() callback on event_trigger_ops is too generic
and is easily confused with other callbacks with that name, so change
it to something that reflects its actual purpose.

In this case, the main purpose of the callback is to implement an
event trigger, so call it trigger() instead.

Also add some more documentation to event_trigger_ops describing the
callbacks a bit better.

Link: https://lkml.kernel.org/r/36ab812e3ee74ee03ae0043fda41a858ee728c00.1641823001.git.zanussi@kernel.org

Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Change event_command func() to parse()</title>
<updated>2022-01-10T16:09:10Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2022-01-10T14:04:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9ec5a7d16899ed9062cc4c3dd3a13e1771411ab3'/>
<id>urn:sha1:9ec5a7d16899ed9062cc4c3dd3a13e1771411ab3</id>
<content type='text'>
The name of the func() callback on event_command is too generic and is
easily confused with other callbacks with that name, so change it to
something that reflects its actual purpose.

In this case, the main purpose of the callback is to parse an event
command, so call it parse() instead.

Link: https://lkml.kernel.org/r/7784e321840752ed88aac0b349c0c685fc9247b1.1641823001.git.zanussi@kernel.org

Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Have eprobes use filtering logic of trace events</title>
<updated>2021-12-06T20:37:22Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-11-30T02:39:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3e8b1a29a0e8d300466cf2a23d2f6d41971c5a0c'/>
<id>urn:sha1:3e8b1a29a0e8d300466cf2a23d2f6d41971c5a0c</id>
<content type='text'>
The eprobes open code the reserving of the event on the ring buffer for
ftrace instead of using the ftrace event wrappers, which means that it
doesn't get affected by the filters, breaking the filtering logic on user
space.

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

Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix misspelling of "missing"</title>
<updated>2021-10-29T13:54:14Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-10-29T13:54:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ddcf906fe5ed842034b2d995064c1de1dcc7e812'/>
<id>urn:sha1:ddcf906fe5ed842034b2d995064c1de1dcc7e812</id>
<content type='text'>
My snake instinct was on and I wrote "misssing" instead of "missing".

Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Do not warn when connecting eprobe to non existing event</title>
<updated>2021-10-28T01:47:55Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-10-27T16:08:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7fa598f9706d40bd16f2ab286bdf5808e1393d35'/>
<id>urn:sha1:7fa598f9706d40bd16f2ab286bdf5808e1393d35</id>
<content type='text'>
When the syscall trace points are not configured in, the kselftests for
ftrace will try to attach an event probe (eprobe) to one of the system
call trace points. This triggered a WARNING, because the failure only
expects to see memory issues. But this is not the only failure. The user
may attempt to attach to a non existent event, and the kernel must not
warn about it.

Link: https://lkml.kernel.org/r/20211027120854.0680aa0f@gandalf.local.home

Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix event probe removal from dynamic events</title>
<updated>2021-10-13T23:26:57Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2021-10-13T20:51:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7d5fda1c841f9f3930eed61b92d542137f93fc30'/>
<id>urn:sha1:7d5fda1c841f9f3930eed61b92d542137f93fc30</id>
<content type='text'>
When an event probe is to be removed via the API that created it via the
dynamic events, an -ENOENT error is returned.

This is because the removal of the event probe does not expect to see the
event system and name that the event probe is attached to, even though
that's part of the API to create it. As the removal of probes is to use
the same API as they are created.

In fact, the removal is not consistent with the kprobes and uprobes
removal. Fix that by allowing various ways to remove the eprobe.

The eprobe is created with:

 e:[GROUP/]NAME SYSTEM/EVENT [OPTIONS]

Have it get removed by echoing in the following into dynamic_events:

 # Remove all eprobes with NAME
 echo '-:NAME' &gt;&gt; dynamic_events

 # Remove a specific eprobe
 echo '-:GROUP/NAME' &gt;&gt; dynamic_events
 echo '-:GROUP/NAME SYSTEM/EVENT' &gt;&gt; dynamic_events
 echo '-:NAME SYSTEM/EVENT' &gt;&gt; dynamic_events
 echo '-:GROUP/NAME SYSTEM/EVENT OPTIONS' &gt;&gt; dynamic_events
 echo '-:NAME SYSTEM/EVENT OPTIONS' &gt;&gt; dynamic_events

Link: https://lkml.kernel.org/r/20211012081925.0e19cc4f@gandalf.local.home
Link: https://lkml.kernel.org/r/20211013205533.630722129@goodmis.org

Suggested-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Acked-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix memory leak in eprobe_register()</title>
<updated>2021-10-11T02:26:55Z</updated>
<author>
<name>Vamshi K Sthambamkadi</name>
<email>vamshi.k.sthambamkadi@gmail.com</email>
</author>
<published>2021-10-08T07:18:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6675880fc4b7c5137a2640b0725505c21b1ac525'/>
<id>urn:sha1:6675880fc4b7c5137a2640b0725505c21b1ac525</id>
<content type='text'>
kmemleak report:
unreferenced object 0xffff900a70ec7ec0 (size 32):
  comm "ftracetest", pid 2770, jiffies 4295042510 (age 311.464s)
  hex dump (first 32 bytes):
    c8 31 23 45 0a 90 ff ff 40 85 c7 6e 0a 90 ff ff  .1#E....@..n....
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;000000009d3751fd&gt;] kmem_cache_alloc_trace+0x2a2/0x440
    [&lt;0000000088b8124b&gt;] eprobe_register+0x1e3/0x350
    [&lt;000000002a9a0517&gt;] __ftrace_event_enable_disable+0x7c/0x240
    [&lt;0000000019109321&gt;] event_enable_write+0x93/0xe0
    [&lt;000000007d85b320&gt;] vfs_write+0xb9/0x260
    [&lt;00000000b94c5e41&gt;] ksys_write+0x67/0xe0
    [&lt;000000005a08c81d&gt;] __x64_sys_write+0x1a/0x20
    [&lt;00000000240bf576&gt;] do_syscall_64+0x3b/0xc0
    [&lt;0000000043d5d9f6&gt;] entry_SYSCALL_64_after_hwframe+0x44/0xae

unreferenced object 0xffff900a56bbf280 (size 128):
  comm "ftracetest", pid 2770, jiffies 4295042510 (age 311.464s)
  hex dump (first 32 bytes):
    ff ff ff ff ff ff ff ff 00 00 00 00 01 00 00 00  ................
    80 69 3b b2 ff ff ff ff 20 69 3b b2 ff ff ff ff  .i;..... i;.....
  backtrace:
    [&lt;000000009d3751fd&gt;] kmem_cache_alloc_trace+0x2a2/0x440
    [&lt;00000000c4e90fad&gt;] eprobe_register+0x1fc/0x350
    [&lt;000000002a9a0517&gt;] __ftrace_event_enable_disable+0x7c/0x240
    [&lt;0000000019109321&gt;] event_enable_write+0x93/0xe0
    [&lt;000000007d85b320&gt;] vfs_write+0xb9/0x260
    [&lt;00000000b94c5e41&gt;] ksys_write+0x67/0xe0
    [&lt;000000005a08c81d&gt;] __x64_sys_write+0x1a/0x20
    [&lt;00000000240bf576&gt;] do_syscall_64+0x3b/0xc0
    [&lt;0000000043d5d9f6&gt;] entry_SYSCALL_64_after_hwframe+0x44/0xae

In new_eprobe_trigger(), allocated edata and trigger variables are
never freed.

To fix, free memory in disable_eprobe().

Link: https://lkml.kernel.org/r/20211008071802.GA2098@cosmos

Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
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: Fix some alloc_event_probe() error handling bugs</title>
<updated>2021-09-08T00:58:23Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2021-08-24T11:51:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5615e088b43d564aec08ccfaecb21ba484a1b4d6'/>
<id>urn:sha1:5615e088b43d564aec08ccfaecb21ba484a1b4d6</id>
<content type='text'>
There are two bugs in this code.  First, if the kzalloc() fails it leads
to a NULL dereference of "ep" on the next line.  Second, if the
alloc_event_probe() function returns an error then it leads to an
error pointer dereference in the caller.

Link: https://lkml.kernel.org/r/20210824115150.GI31143@kili

Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
