<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace_events_synth.c, branch v6.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=v6.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-08-01T20:49:15Z</updated>
<entry>
<title>tracing: Add guard(ring_buffer_nest)</title>
<updated>2025-08-01T20:49:15Z</updated>
<author>
<name>Steven Rostedt</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2025-08-01T20:37:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=788fa4b47cdcd9b3d8c2d02ac0b3cd2540305f18'/>
<id>urn:sha1:788fa4b47cdcd9b3d8c2d02ac0b3cd2540305f18</id>
<content type='text'>
Some calls to the tracing ring buffer can happen when the ring buffer is
already being written to by the same context (for example, a
trace_printk() in between a ring_buffer_lock_reserve() and a
ring_buffer_unlock_commit()).

In order to not trigger the recursion detection, these functions use
ring_buffer_nest_start() and ring_buffer_nest_end(). Create a guard() for
these functions so that their use cases can be simplified and not need to
use goto for the release.

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mark Rutland &lt;mark.rutland@arm.com&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Link: https://lore.kernel.org/20250801203857.710501021@kernel.org
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Do not add length to print format in synthetic events</title>
<updated>2025-04-09T15:34:21Z</updated>
<author>
<name>Steven Rostedt</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2025-04-07T19:41:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e1a453a57bc76be678bd746f84e3d73f378a9511'/>
<id>urn:sha1:e1a453a57bc76be678bd746f84e3d73f378a9511</id>
<content type='text'>
The following causes a vsnprintf fault:

  # echo 's:wake_lat char[] wakee; u64 delta;' &gt;&gt; /sys/kernel/tracing/dynamic_events
  # echo 'hist:keys=pid:ts=common_timestamp.usecs if !(common_flags &amp; 0x18)' &gt; /sys/kernel/tracing/events/sched/sched_waking/trigger
  # echo 'hist:keys=next_pid:delta=common_timestamp.usecs-$ts:onmatch(sched.sched_waking).trace(wake_lat,next_comm,$delta)' &gt; /sys/kernel/tracing/events/sched/sched_switch/trigger

Because the synthetic event's "wakee" field is created as a dynamic string
(even though the string copied is not). The print format to print the
dynamic string changed from "%*s" to "%s" because another location
(__set_synth_event_print_fmt()) exported this to user space, and user
space did not need that. But it is still used in print_synth_event(), and
the output looks like:

          &lt;idle&gt;-0       [001] d..5.   193.428167: wake_lat: wakee=(efault)sshd-sessiondelta=155
    sshd-session-879     [001] d..5.   193.811080: wake_lat: wakee=(efault)kworker/u34:5delta=58
          &lt;idle&gt;-0       [002] d..5.   193.811198: wake_lat: wakee=(efault)bashdelta=91
            bash-880     [002] d..5.   193.811371: wake_lat: wakee=(efault)kworker/u35:2delta=21
          &lt;idle&gt;-0       [001] d..5.   193.811516: wake_lat: wakee=(efault)sshd-sessiondelta=129
    sshd-session-879     [001] d..5.   193.967576: wake_lat: wakee=(efault)kworker/u34:5delta=50

The length isn't needed as the string is always nul terminated. Just print
the string and not add the length (which was hard coded to the max string
length anyway).

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Tom Zanussi &lt;zanussi@kernel.org&gt;
Cc: Douglas Raillard &lt;douglas.raillard@arm.com&gt;
Acked-by: Masami Hiramatsu (Google) &lt;mhiramat@kernel.org&gt;
Link: https://lore.kernel.org/20250407154139.69955768@gandalf.local.home
Fixes: 4d38328eb442d ("tracing: Fix synth event printk format for str fields");
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Replace strncpy with memcpy for fixed-length substring copy</title>
<updated>2025-03-25T21:44:32Z</updated>
<author>
<name>Siddarth G</name>
<email>siddarthsgml@gmail.com</email>
</author>
<published>2025-03-25T18:12:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e0344f9564f5847dc20e245fbea67a4b262ee659'/>
<id>urn:sha1:e0344f9564f5847dc20e245fbea67a4b262ee659</id>
<content type='text'>
checkpatch.pl reports the following warning:
WARNING: Prefer strscpy, strscpy_pad, or __nonstring over strncpy
(see: https://github.com/KSPP/linux/issues/90)

In synth_field_string_size(), replace strncpy() with memcpy() to copy 'len'
characters from 'start' to 'buf'. The code manually adds a NUL terminator
after the copy, making memcpy safe here.

Link: https://lore.kernel.org/20250325181232.38284-1-siddarthsgml@gmail.com
Signed-off-by: Siddarth G &lt;siddarthsgml@gmail.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix synth event printk format for str fields</title>
<updated>2025-03-25T21:42:38Z</updated>
<author>
<name>Douglas Raillard</name>
<email>douglas.raillard@arm.com</email>
</author>
<published>2025-03-25T16:52:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4d38328eb442dc06aec4350fd9594ffa6488af02'/>
<id>urn:sha1:4d38328eb442dc06aec4350fd9594ffa6488af02</id>
<content type='text'>
The printk format for synth event uses "%.*s" to print string fields,
but then only passes the pointer part as var arg.

Replace %.*s with %s as the C string is guaranteed to be null-terminated.

The output in print fmt should never have been updated as __get_str()
handles the string limit because it can access the length of the string in
the string meta data that is saved in the ring buffer.

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Fixes: 8db4d6bfbbf92 ("tracing: Change synthetic event string format to limit printed length")
Link: https://lore.kernel.org/20250325165202.541088-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard &lt;douglas.raillard@arm.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Do not use PERF enums when perf is not defined</title>
<updated>2025-03-24T21:12:33Z</updated>
<author>
<name>Steven Rostedt</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2025-03-23T19:21:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8eb1518642738c6892bd629b46043513a3bf1a6a'/>
<id>urn:sha1:8eb1518642738c6892bd629b46043513a3bf1a6a</id>
<content type='text'>
An update was made to up the module ref count when a synthetic event is
registered for both trace and perf events. But if perf is not configured
in, the perf enums used will cause the kernel to fail to build.

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Douglas Raillard &lt;douglas.raillard@arm.com&gt;
Link: https://lore.kernel.org/20250323152151.528b5ced@batman.local.home
Fixes: 21581dd4e7ff ("tracing: Ensure module defining synth event cannot be unloaded while tracing")
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Closes: https://lore.kernel.org/oe-kbuild-all/202503232230.TeREVy8R-lkp@intel.com/
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Ensure module defining synth event cannot be unloaded while tracing</title>
<updated>2025-03-23T12:34:31Z</updated>
<author>
<name>Douglas Raillard</name>
<email>douglas.raillard@arm.com</email>
</author>
<published>2025-03-18T18:09:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=21581dd4e7ff6c07d0ab577e3c32b13a74b31522'/>
<id>urn:sha1:21581dd4e7ff6c07d0ab577e3c32b13a74b31522</id>
<content type='text'>
Currently, using synth_event_delete() will fail if the event is being
used (tracing in progress), but that is normally done in the module exit
function. At that stage, failing is problematic as returning a non-zero
status means the module will become locked (impossible to unload or
reload again).

Instead, ensure the module exit function does not get called in the
first place by increasing the module refcnt when the event is enabled.

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Fixes: 35ca5207c2d11 ("tracing: Add synthetic event command generation functions")
Link: https://lore.kernel.org/20250318180906.226841-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard &lt;douglas.raillard@arm.com&gt;
Acked-by: Masami Hiramatsu (Google) &lt;mhiramat@kernel.org&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Align synth event print fmt</title>
<updated>2025-03-23T12:34:31Z</updated>
<author>
<name>Douglas Raillard</name>
<email>douglas.raillard@arm.com</email>
</author>
<published>2025-03-19T21:50:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=81c7a515b0f1e1254edd8adcfa1b780c31833565'/>
<id>urn:sha1:81c7a515b0f1e1254edd8adcfa1b780c31833565</id>
<content type='text'>
The vast majority of ftrace event print fmt consist of a space-separated
field=value pair. Synthetic event currently use a comma-separated
field=value pair, which sticks out from events created via more
classical means.

Align the format of synth events so they look just like any other event,
for better consistency and less headache when doing crude text-based
data processing.

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Link: https://lore.kernel.org/20250319215028.1680278-1-douglas.raillard@arm.com
Signed-off-by: Douglas Raillard &lt;douglas.raillard@arm.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Switch trace_events_synth.c code over to use guard()</title>
<updated>2024-12-26T15:38:37Z</updated>
<author>
<name>Steven Rostedt</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2024-12-19T20:12:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a2e27e1bb19eb7c1790af7c8b6f7298ec524c1bb'/>
<id>urn:sha1:a2e27e1bb19eb7c1790af7c8b6f7298ec524c1bb</id>
<content type='text'>
There are a couple functions in trace_events_synth.c that have "goto out"
or equivalent on error in order to release locks that were taken. This can
be error prone or just simply make the code more complex.

Switch every location that ends with unlocking a mutex on error over to
using the guard(mutex)() infrastructure to let the compiler worry about
releasing locks. This makes the code easier to read and understand.

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mark Rutland &lt;mark.rutland@arm.com&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/20241219201346.371082515@goodmis.org
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/synthetic: Fix trace_string() return value</title>
<updated>2024-02-15T16:40:01Z</updated>
<author>
<name>Thorsten Blum</name>
<email>thorsten.blum@toblux.com</email>
</author>
<published>2024-02-14T22:05:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9b6326354cf9a41521b79287da3bfab022ae0b6d'/>
<id>urn:sha1:9b6326354cf9a41521b79287da3bfab022ae0b6d</id>
<content type='text'>
Fix trace_string() by assigning the string length to the return variable
which got lost in commit ddeea494a16f ("tracing/synthetic: Use union
instead of casts") and caused trace_string() to always return 0.

Link: https://lore.kernel.org/linux-trace-kernel/20240214220555.711598-1-thorsten.blum@toblux.com

Cc: stable@vger.kernel.org
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Fixes: ddeea494a16f ("tracing/synthetic: Use union instead of casts")
Acked-by: Masami Hiramatsu (Google) &lt;mhiramat@kernel.org&gt;
Signed-off-by: Thorsten Blum &lt;thorsten.blum@toblux.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/synthetic: fix kernel-doc warnings</title>
<updated>2023-12-20T17:51:03Z</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2023-12-20T06:12:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7beb82b7d590e51f698b1cf590b0e2785db1c498'/>
<id>urn:sha1:7beb82b7d590e51f698b1cf590b0e2785db1c498</id>
<content type='text'>
scripts/kernel-doc warns about using @args: for variadic arguments to
functions. Documentation/doc-guide/kernel-doc.rst says that this should
be written as @...: instead, so update the source code to match that,
preventing the warnings.

trace_events_synth.c:1165: warning: Excess function parameter 'args' description in '__synth_event_gen_cmd_start'
trace_events_synth.c:1714: warning: Excess function parameter 'args' description in 'synth_event_trace'

Link: https://lore.kernel.org/linux-trace-kernel/20231220061226.30962-1-rdunlap@infradead.org

Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Fixes: 35ca5207c2d11 ("tracing: Add synthetic event command generation functions")
Fixes: 8dcc53ad956d2 ("tracing: Add synth_event_trace() and related functions")
Acked-by: Masami Hiramatsu (Google) &lt;mhiramat@kernel.org&gt;
Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
