Skip to content

Commit a2ded78

Browse files
committed
Merge tag 'trace-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt: - Allow kernel trace instance creation to specify what events are created Inside the kernel, a subsystem may create a tracing instance that it can use to send events to user space. This sub-system may not care about the thousands of events that exist in eventfs. Allow the sub-system to specify what sub-systems of events it cares about, and only those events are exposed to this instance. - Allow the ring buffer to be broken up into bigger sub-buffers than just the architecture page size. A new tracefs file called "buffer_subbuf_size_kb" is created. The user can now specify a minimum size the sub-buffer may be in kilobytes. Note, that the implementation currently make the sub-buffer size a power of 2 pages (1, 2, 4, 8, 16, ...) but the user only writes in kilobyte size, and the sub-buffer will be updated to the next size that it will can accommodate it. If the user writes in 10, it will change the size to be 4 pages on x86 (16K), as that is the next available size that can hold 10K pages. - Update the debug output when a corrupt time is detected in the ring buffer. If the ring buffer detects inconsistent timestamps, there's a debug config options that will dump the contents of the meta data of the sub-buffer that is used for debugging. Add some more information to this dump that helps with debugging. - Add more timestamp debugging checks (only triggers when the config is enabled) - Increase the trace_seq iterator to 2 page sizes. - Allow strings written into tracefs_marker to be larger. Up to just under 2 page sizes (based on what trace_seq can hold). - Increase the trace_maker_raw write to be as big as a sub-buffer can hold. - Remove 32 bit time stamp logic, now that the rb_time_cmpxchg() has been removed. - More selftests were added. - Some code clean ups as well. * tag 'trace-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (29 commits) ring-buffer: Remove stale comment from ring_buffer_size() tracing histograms: Simplify parse_actions() function tracing/selftests: Remove exec permissions from trace_marker.tc test ring-buffer: Use subbuf_order for buffer page masking tracing: Update subbuffer with kilobytes not page order ringbuffer/selftest: Add basic selftest to test changing subbuf order ring-buffer: Add documentation on the buffer_subbuf_order file ring-buffer: Just update the subbuffers when changing their allocation order ring-buffer: Keep the same size when updating the order tracing: Stop the tracing while changing the ring buffer subbuf size tracing: Update snapshot order along with main buffer order ring-buffer: Make sure the spare sub buffer used for reads has same size ring-buffer: Do no swap cpu buffers if order is different ring-buffer: Clear pages on error in ring_buffer_subbuf_order_set() failure ring-buffer: Read and write to ring buffers with custom sub buffer size ring-buffer: Set new size of the ring buffer sub page ring-buffer: Add interface for configuring trace sub buffer size ring-buffer: Page size per ring buffer ring-buffer: Have ring_buffer_print_page_header() be able to access ring_buffer_iter ring-buffer: Check if absolute timestamp goes backwards ...
2 parents 5b890ad + 25742ae commit a2ded78

16 files changed

Lines changed: 999 additions & 374 deletions

File tree

Documentation/trace/ftrace.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,27 @@ of ftrace. Here is a list of some of the key files:
218218

219219
This displays the total combined size of all the trace buffers.
220220

221+
buffer_subbuf_size_kb:
222+
223+
This sets or displays the sub buffer size. The ring buffer is broken up
224+
into several same size "sub buffers". An event can not be bigger than
225+
the size of the sub buffer. Normally, the sub buffer is the size of the
226+
architecture's page (4K on x86). The sub buffer also contains meta data
227+
at the start which also limits the size of an event. That means when
228+
the sub buffer is a page size, no event can be larger than the page
229+
size minus the sub buffer meta data.
230+
231+
Note, the buffer_subbuf_size_kb is a way for the user to specify the
232+
minimum size of the subbuffer. The kernel may make it bigger due to the
233+
implementation details, or simply fail the operation if the kernel can
234+
not handle the request.
235+
236+
Changing the sub buffer size allows for events to be larger than the
237+
page size.
238+
239+
Note: When changing the sub-buffer size, tracing is stopped and any
240+
data in the ring buffer and the snapshot buffer will be discarded.
241+
221242
free_buffer:
222243

223244
If a process is performing tracing, and the ring buffer should be

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,7 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)
28892889
static void
28902890
qla_trace_init(void)
28912891
{
2892-
qla_trc_array = trace_array_get_by_name("qla2xxx");
2892+
qla_trc_array = trace_array_get_by_name("qla2xxx", NULL);
28932893
if (!qla_trc_array) {
28942894
ql_log(ql_log_fatal, NULL, 0x0001,
28952895
"Unable to create qla2xxx trace instance, instance logging will be disabled.\n");

include/linux/ring_buffer.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int ring_buffer_iter_empty(struct ring_buffer_iter *iter);
141141
bool ring_buffer_iter_dropped(struct ring_buffer_iter *iter);
142142

143143
unsigned long ring_buffer_size(struct trace_buffer *buffer, int cpu);
144+
unsigned long ring_buffer_max_event_size(struct trace_buffer *buffer);
144145

145146
void ring_buffer_reset_cpu(struct trace_buffer *buffer, int cpu);
146147
void ring_buffer_reset_online_cpus(struct trace_buffer *buffer);
@@ -191,15 +192,24 @@ bool ring_buffer_time_stamp_abs(struct trace_buffer *buffer);
191192
size_t ring_buffer_nr_pages(struct trace_buffer *buffer, int cpu);
192193
size_t ring_buffer_nr_dirty_pages(struct trace_buffer *buffer, int cpu);
193194

194-
void *ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu);
195-
void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu, void *data);
196-
int ring_buffer_read_page(struct trace_buffer *buffer, void **data_page,
195+
struct buffer_data_read_page;
196+
struct buffer_data_read_page *
197+
ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu);
198+
void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu,
199+
struct buffer_data_read_page *page);
200+
int ring_buffer_read_page(struct trace_buffer *buffer,
201+
struct buffer_data_read_page *data_page,
197202
size_t len, int cpu, int full);
203+
void *ring_buffer_read_page_data(struct buffer_data_read_page *page);
198204

199205
struct trace_seq;
200206

201207
int ring_buffer_print_entry_header(struct trace_seq *s);
202-
int ring_buffer_print_page_header(struct trace_seq *s);
208+
int ring_buffer_print_page_header(struct trace_buffer *buffer, struct trace_seq *s);
209+
210+
int ring_buffer_subbuf_order_get(struct trace_buffer *buffer);
211+
int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order);
212+
int ring_buffer_subbuf_size_get(struct trace_buffer *buffer);
203213

204214
enum ring_buffer_flags {
205215
RB_FL_OVERWRITE = 1 << 0,

include/linux/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int trace_array_printk(struct trace_array *tr, unsigned long ip,
5151
const char *fmt, ...);
5252
int trace_array_init_printk(struct trace_array *tr);
5353
void trace_array_put(struct trace_array *tr);
54-
struct trace_array *trace_array_get_by_name(const char *name);
54+
struct trace_array *trace_array_get_by_name(const char *name, const char *systems);
5555
int trace_array_destroy(struct trace_array *tr);
5656

5757
/* For osnoise tracer */
@@ -84,7 +84,7 @@ static inline int trace_array_init_printk(struct trace_array *tr)
8484
static inline void trace_array_put(struct trace_array *tr)
8585
{
8686
}
87-
static inline struct trace_array *trace_array_get_by_name(const char *name)
87+
static inline struct trace_array *trace_array_get_by_name(const char *name, const char *systems)
8888
{
8989
return NULL;
9090
}

include/linux/trace_seq.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
/*
1010
* Trace sequences are used to allow a function to call several other functions
11-
* to create a string of data to use (up to a max of PAGE_SIZE).
11+
* to create a string of data to use.
1212
*/
1313

14+
#define TRACE_SEQ_BUFFER_SIZE (PAGE_SIZE * 2 - \
15+
(sizeof(struct seq_buf) + sizeof(size_t) + sizeof(int)))
16+
1417
struct trace_seq {
15-
char buffer[PAGE_SIZE];
18+
char buffer[TRACE_SEQ_BUFFER_SIZE];
1619
struct seq_buf seq;
1720
size_t readpos;
1821
int full;
@@ -21,7 +24,7 @@ struct trace_seq {
2124
static inline void
2225
trace_seq_init(struct trace_seq *s)
2326
{
24-
seq_buf_init(&s->seq, s->buffer, PAGE_SIZE);
27+
seq_buf_init(&s->seq, s->buffer, TRACE_SEQ_BUFFER_SIZE);
2528
s->full = 0;
2629
s->readpos = 0;
2730
}

0 commit comments

Comments
 (0)