<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace.c, branch v6.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://www.git.shady.money/linux/atom?h=v6.1</id>
<link rel='self' href='https://www.git.shady.money/linux/atom?h=v6.1'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/'/>
<updated>2022-11-24T00:06:11Z</updated>
<entry>
<title>tracing: Add tracing_reset_all_online_cpus_unlocked() function</title>
<updated>2022-11-24T00:06:11Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-11-23T19:25:57Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=e18eb8783ec4949adebc7d7b0fdb65f65bfeefd9'/>
<id>urn:sha1:e18eb8783ec4949adebc7d7b0fdb65f65bfeefd9</id>
<content type='text'>
Currently the tracing_reset_all_online_cpus() requires the
trace_types_lock held. But only one caller of this function actually has
that lock held before calling it, and the other just takes the lock so
that it can call it. More users of this function is needed where the lock
is not held.

Add a tracing_reset_all_online_cpus_unlocked() function for the one use
case that calls it without being held, and also add a lockdep_assert to
make sure it is held when called.

Then have tracing_reset_all_online_cpus() take the lock internally, such
that callers do not need to worry about taking it.

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

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Zheng Yejian &lt;zhengyejian1@huawei.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix potential null-pointer-access of entry in list 'tr-&gt;err_log'</title>
<updated>2022-11-18T01:41:01Z</updated>
<author>
<name>Zheng Yejian</name>
<email>zhengyejian1@huawei.com</email>
</author>
<published>2022-11-14T10:46:32Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=067df9e0ad48a97382ab2179bbe773a13a846028'/>
<id>urn:sha1:067df9e0ad48a97382ab2179bbe773a13a846028</id>
<content type='text'>
Entries in list 'tr-&gt;err_log' will be reused after entry number
exceed TRACING_LOG_ERRS_MAX.

The cmd string of the to be reused entry will be freed first then
allocated a new one. If the allocation failed, then the entry will
still be in list 'tr-&gt;err_log' but its 'cmd' field is set to be NULL,
later access of 'cmd' is risky.

Currently above problem can cause the loss of 'cmd' information of first
entry in 'tr-&gt;err_log'. When execute `cat /sys/kernel/tracing/error_log`,
reproduce logs like:
  [   37.495100] trace_kprobe: error: Maxactive is not for kprobe(null) ^
  [   38.412517] trace_kprobe: error: Maxactive is not for kprobe
    Command: p4:myprobe2 do_sys_openat2
            ^

Link: https://lore.kernel.org/linux-trace-kernel/20221114104632.3547266-1-zhengyejian1@huawei.com

Fixes: 1581a884b7ca ("tracing: Remove size restriction on tracing_log_err cmd strings")
Signed-off-by: Zheng Yejian &lt;zhengyejian1@huawei.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: Fix memory leak in tracing_read_pipe()</title>
<updated>2022-11-17T01:29:00Z</updated>
<author>
<name>Wang Yufen</name>
<email>wangyufen@huawei.com</email>
</author>
<published>2022-11-07T11:04:50Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=649e72070cbbb8600eb823833e4748f5a0815116'/>
<id>urn:sha1:649e72070cbbb8600eb823833e4748f5a0815116</id>
<content type='text'>
kmemleak reports this issue:

unreferenced object 0xffff888105a18900 (size 128):
  comm "test_progs", pid 18933, jiffies 4336275356 (age 22801.766s)
  hex dump (first 32 bytes):
    25 73 00 90 81 88 ff ff 26 05 00 00 42 01 58 04  %s......&amp;...B.X.
    03 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;00000000560143a1&gt;] __kmalloc_node_track_caller+0x4a/0x140
    [&lt;000000006af00822&gt;] krealloc+0x8d/0xf0
    [&lt;00000000c309be6a&gt;] trace_iter_expand_format+0x99/0x150
    [&lt;000000005a53bdb6&gt;] trace_check_vprintf+0x1e0/0x11d0
    [&lt;0000000065629d9d&gt;] trace_event_printf+0xb6/0xf0
    [&lt;000000009a690dc7&gt;] trace_raw_output_bpf_trace_printk+0x89/0xc0
    [&lt;00000000d22db172&gt;] print_trace_line+0x73c/0x1480
    [&lt;00000000cdba76ba&gt;] tracing_read_pipe+0x45c/0x9f0
    [&lt;0000000015b58459&gt;] vfs_read+0x17b/0x7c0
    [&lt;000000004aeee8ed&gt;] ksys_read+0xed/0x1c0
    [&lt;0000000063d3d898&gt;] do_syscall_64+0x3b/0x90
    [&lt;00000000a06dda7f&gt;] entry_SYSCALL_64_after_hwframe+0x63/0xcd

iter-&gt;fmt alloced in
  tracing_read_pipe() -&gt; .. -&gt;trace_iter_expand_format(), but not
freed, to fix, add free in tracing_release_pipe()

Link: https://lkml.kernel.org/r/1667819090-4643-1-git-send-email-wangyufen@huawei.com

Cc: stable@vger.kernel.org
Fixes: efbbdaa22bb7 ("tracing: Show real address for trace event arguments")
Acked-by: Masami Hiramatsu (Google) &lt;mhiramat@kernel.org&gt;
Signed-off-by: Wang Yufen &lt;wangyufen@huawei.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing/ring-buffer: Have polling block on watermark</title>
<updated>2022-11-16T22:13:04Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-10-21T03:14:27Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=42fb0a1e84ff525ebe560e2baf9451ab69127e2b'/>
<id>urn:sha1:42fb0a1e84ff525ebe560e2baf9451ab69127e2b</id>
<content type='text'>
Currently the way polling works on the ring buffer is broken. It will
return immediately if there's any data in the ring buffer whereas a read
will block until the watermark (defined by the tracefs buffer_percent file)
is hit.

That is, a select() or poll() will return as if there's data available,
but then the following read will block. This is broken for the way
select()s and poll()s are supposed to work.

Have the polling on the ring buffer also block the same way reads and
splice does on the ring buffer.

Link: https://lkml.kernel.org/r/20221020231427.41be3f26@gandalf.local.home

Cc: Linux Trace Kernel &lt;linux-trace-kernel@vger.kernel.org&gt;
Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Primiano Tucci &lt;primiano@google.com&gt;
Cc: stable@vger.kernel.org
Fixes: 1e0d6714aceb7 ("ring-buffer: Do not wake up a splice waiter when page is not full")
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Do not free snapshot if tracer is on cmdline</title>
<updated>2022-10-06T02:18:23Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-10-05T15:37:57Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=a541a9559bb0a8ecc434de01d3e4826c32e8bb53'/>
<id>urn:sha1:a541a9559bb0a8ecc434de01d3e4826c32e8bb53</id>
<content type='text'>
The ftrace_boot_snapshot and alloc_snapshot cmdline options allocate the
snapshot buffer at boot up for use later. The ftrace_boot_snapshot in
particular requires the snapshot to be allocated because it will take a
snapshot at the end of boot up allowing to see the traces that happened
during boot so that it's not lost when user space takes over.

When a tracer is registered (started) there's a path that checks if it
requires the snapshot buffer or not, and if it does not and it was
allocated it will do a synchronization and free the snapshot buffer.

This is only required if the previous tracer was using it for "max
latency" snapshots, as it needs to make sure all max snapshots are
complete before freeing. But this is only needed if the previous tracer
was using the snapshot buffer for latency (like irqoff tracer and
friends). But it does not make sense to free it, if the previous tracer
was not using it, and the snapshot was allocated by the cmdline
parameters. This basically takes away the point of allocating it in the
first place!

Note, the allocated snapshot worked fine for just trace events, but fails
when a tracer is enabled on the cmdline.

Further investigation, this goes back even further and it does not require
a tracer on the cmdline to fail. Simply enable snapshots and then enable a
tracer, and it will remove the snapshot.

Link: https://lkml.kernel.org/r/20221005113757.041df7fe@gandalf.local.home

Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: stable@vger.kernel.org
Fixes: 45ad21ca5530 ("tracing: Have trace_array keep track if snapshot buffer is allocated")
Reported-by: Ross Zwisler &lt;zwisler@kernel.org&gt;
Tested-by: Ross Zwisler &lt;zwisler@kernel.org&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix spelling mistake "preapre" -&gt; "prepare"</title>
<updated>2022-09-29T14:17:35Z</updated>
<author>
<name>Colin Ian King</name>
<email>colin.i.king@gmail.com</email>
</author>
<published>2022-09-28T21:58:28Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=e841e8bfac490957fed3157326b96342dc76798a'/>
<id>urn:sha1:e841e8bfac490957fed3157326b96342dc76798a</id>
<content type='text'>
There is a spelling mistake in the trace text. Fix it.

Link: https://lkml.kernel.org/r/20220928215828.66325-1-colin.i.king@gmail.com

Signed-off-by: Colin Ian King &lt;colin.i.king@gmail.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Wake up waiters when tracing is disabled</title>
<updated>2022-09-29T14:17:35Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-09-28T22:22:20Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=2b0fd9a59b7990c161fa1cb7b79edb22847c87c2'/>
<id>urn:sha1:2b0fd9a59b7990c161fa1cb7b79edb22847c87c2</id>
<content type='text'>
When tracing is disabled, there's no reason that waiters should stay
waiting, wake them up, otherwise tasks get stuck when they should be
flushing the buffers.

Cc: stable@vger.kernel.org
Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice")
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Add ioctl() to force ring buffer waiters to wake up</title>
<updated>2022-09-29T14:17:18Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-09-29T13:50:29Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=01b2a52171735c6eea80ee2f355f32bea6c41418'/>
<id>urn:sha1:01b2a52171735c6eea80ee2f355f32bea6c41418</id>
<content type='text'>
If a process is waiting on the ring buffer for data, there currently isn't
a clean way to force it to wake up. Add an ioctl call that will force any
tasks that are waiting on the trace_pipe_raw file to wake up.

Link: https://lkml.kernel.org/r/20220929095029.117f913f@gandalf.local.home

Cc: stable@vger.kernel.org
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice")
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Wake up ring buffer waiters on closing of the file</title>
<updated>2022-09-29T00:28:13Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-09-27T23:15:27Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=f3ddb74ad0790030c9592229fb14d8c451f4e9a8'/>
<id>urn:sha1:f3ddb74ad0790030c9592229fb14d8c451f4e9a8</id>
<content type='text'>
When the file that represents the ring buffer is closed, there may be
waiters waiting on more input from the ring buffer. Call
ring_buffer_wake_waiters() to wake up any waiters when the file is
closed.

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

Cc: stable@vger.kernel.org
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice")
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Disable interrupt or preemption before acquiring arch_spinlock_t</title>
<updated>2022-09-27T18:48:11Z</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2022-09-22T14:56:22Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/linux/commit/?id=c0a581d7126c0bbc96163276f585fd7b4e4d8d0e'/>
<id>urn:sha1:c0a581d7126c0bbc96163276f585fd7b4e4d8d0e</id>
<content type='text'>
It was found that some tracing functions in kernel/trace/trace.c acquire
an arch_spinlock_t with preemption and irqs enabled. An example is the
tracing_saved_cmdlines_size_read() function which intermittently causes
a "BUG: using smp_processor_id() in preemptible" warning when the LTP
read_all_proc test is run.

That can be problematic in case preemption happens after acquiring the
lock. Add the necessary preemption or interrupt disabling code in the
appropriate places before acquiring an arch_spinlock_t.

The convention here is to disable preemption for trace_cmdline_lock and
interupt for max_lock.

Link: https://lkml.kernel.org/r/20220922145622.1744826-1-longman@redhat.com

Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
Cc: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Cc: stable@vger.kernel.org
Fixes: a35873a0993b ("tracing: Add conditional snapshot")
Fixes: 939c7a4f04fc ("tracing: Introduce saved_cmdlines_size file")
Suggested-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
