Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-v6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:

- Fix sample code that uses trace_array_printk()

The sample code for in kernel use of trace_array (that creates an
instance for use within the kernel) and shows how to use
trace_array_printk() that writes into the created instance, used
trace_printk_init_buffers(). But that function is used to initialize
normal trace_printk() and produces the NOTICE banner which is not
needed for use of trace_array_printk(). The function to initialize
that is trace_array_init_printk() that takes the created trace array
instance as a parameter.

Update the sample code to reflect the proper usage.

- Fix preemption count output for stacktrace event

The tracing buffer shows the preempt count level when an event
executes. Because writing the event itself disables preemption, this
needs to be accounted for when recording. The stacktrace event did
not account for this so the output of the stacktrace event showed
preemption was disabled while the event that triggered the stacktrace
shows preemption is enabled and this leads to confusion. Account for
preemption being disabled for the stacktrace event.

The same happened for stack traces triggered by function tracer.

- Fix persistent ring buffer when trace_pipe is used

The ring buffer swaps the reader page with the next page to read from
the write buffer when trace_pipe is used. If there's only a page of
data in the ring buffer, this swap will cause the "commit" pointer
(last data written) to be on the reader page. If more data is written
to the buffer, it is added to the reader page until it falls off back
into the write buffer.

If the system reboots and the commit pointer is still on the reader
page, even if new data was written, the persistent buffer validator
will miss finding the commit pointer because it only checks the write
buffer and does not check the reader page. This causes the validator
to fail the validation and clear the buffer, where the new data is
lost.

There was a check for this, but it checked the "head pointer", which
was incorrect, because the "head pointer" always stays on the write
buffer and is the next page to swap out for the reader page. Fix the
logic to catch this case and allow the user to still read the data
after reboot.

* tag 'trace-v6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
ring-buffer: Fix persistent buffer when commit page is the reader page
ftrace: Fix preemption accounting for stacktrace filter command
ftrace: Fix preemption accounting for stacktrace trigger command
tracing: samples: Initialize trace_array_printk() with the correct function

+8 -10
+5 -3
kernel/trace/ring_buffer.c
··· 1887 1887 1888 1888 head_page = cpu_buffer->head_page; 1889 1889 1890 - /* If both the head and commit are on the reader_page then we are done. */ 1891 - if (head_page == cpu_buffer->reader_page && 1892 - head_page == cpu_buffer->commit_page) 1890 + /* If the commit_buffer is the reader page, update the commit page */ 1891 + if (meta->commit_buffer == (unsigned long)cpu_buffer->reader_page->page) { 1892 + cpu_buffer->commit_page = cpu_buffer->reader_page; 1893 + /* Nothing more to do, the only page is the reader page */ 1893 1894 goto done; 1895 + } 1894 1896 1895 1897 /* Iterate until finding the commit page */ 1896 1898 for (i = 0; i < meta->nr_subbufs + 1; i++, rb_inc_page(&head_page)) {
+1 -1
kernel/trace/trace_events_trigger.c
··· 1560 1560 struct trace_event_file *file = data->private_data; 1561 1561 1562 1562 if (file) 1563 - __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP); 1563 + __trace_stack(file->tr, tracing_gen_ctx_dec(), STACK_SKIP); 1564 1564 else 1565 1565 trace_dump_stack(STACK_SKIP); 1566 1566 }
+1 -5
kernel/trace/trace_functions.c
··· 633 633 634 634 static __always_inline void trace_stack(struct trace_array *tr) 635 635 { 636 - unsigned int trace_ctx; 637 - 638 - trace_ctx = tracing_gen_ctx(); 639 - 640 - __trace_stack(tr, trace_ctx, FTRACE_STACK_SKIP); 636 + __trace_stack(tr, tracing_gen_ctx_dec(), FTRACE_STACK_SKIP); 641 637 } 642 638 643 639 static void
+1 -1
samples/ftrace/sample-trace-array.c
··· 112 112 /* 113 113 * If context specific per-cpu buffers havent already been allocated. 114 114 */ 115 - trace_printk_init_buffers(); 115 + trace_array_init_printk(tr); 116 116 117 117 simple_tsk = kthread_run(simple_thread, NULL, "sample-instance"); 118 118 if (IS_ERR(simple_tsk)) {