Skip to content

Commit 6d98a0f

Browse files
Zheng Yejianrostedt
authored andcommitted
tracing: Set actual size after ring buffer resize
Currently we can resize trace ringbuffer by writing a value into file 'buffer_size_kb', then by reading the file, we get the value that is usually what we wrote. However, this value may be not actual size of trace ring buffer because of the round up when doing resize in kernel, and the actual size would be more useful. Link: https://lore.kernel.org/linux-trace-kernel/20230705002705.576633-1-zhengyejian1@huawei.com Cc: <mhiramat@kernel.org> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 6bba928 commit 6d98a0f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

kernel/trace/trace.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6286,6 +6286,15 @@ static void set_buffer_entries(struct array_buffer *buf, unsigned long val)
62866286
per_cpu_ptr(buf->data, cpu)->entries = val;
62876287
}
62886288

6289+
static void update_buffer_entries(struct array_buffer *buf, int cpu)
6290+
{
6291+
if (cpu == RING_BUFFER_ALL_CPUS) {
6292+
set_buffer_entries(buf, ring_buffer_size(buf->buffer, 0));
6293+
} else {
6294+
per_cpu_ptr(buf->data, cpu)->entries = ring_buffer_size(buf->buffer, cpu);
6295+
}
6296+
}
6297+
62896298
#ifdef CONFIG_TRACER_MAX_TRACE
62906299
/* resize @tr's buffer to the size of @size_tr's entries */
62916300
static int resize_buffer_duplicate_size(struct array_buffer *trace_buf,
@@ -6364,18 +6373,12 @@ static int __tracing_resize_ring_buffer(struct trace_array *tr,
63646373
return ret;
63656374
}
63666375

6367-
if (cpu == RING_BUFFER_ALL_CPUS)
6368-
set_buffer_entries(&tr->max_buffer, size);
6369-
else
6370-
per_cpu_ptr(tr->max_buffer.data, cpu)->entries = size;
6376+
update_buffer_entries(&tr->max_buffer, cpu);
63716377

63726378
out:
63736379
#endif /* CONFIG_TRACER_MAX_TRACE */
63746380

6375-
if (cpu == RING_BUFFER_ALL_CPUS)
6376-
set_buffer_entries(&tr->array_buffer, size);
6377-
else
6378-
per_cpu_ptr(tr->array_buffer.data, cpu)->entries = size;
6381+
update_buffer_entries(&tr->array_buffer, cpu);
63796382

63806383
return ret;
63816384
}

0 commit comments

Comments
 (0)