Ring buffer fixes for 6.12:
- Revert: "ring-buffer: Do not have boot mapped buffers hook to CPU hotplug" A crash that happened on cpu hotplug was actually caused by the incorrect ref counting that was fixed by commit2cf9733891
("ring-buffer: Fix refcount setting of boot mapped buffers"). The removal of calling cpu hotplug callbacks on memory mapped buffers was not an issue even though the tests at the time pointed toward it. But in fact, there's a check in that code that tests to see if the buffers are already allocated or not, and will not allocate them again if they are. Not calling the cpu hotplug callbacks ended up not initializing the non boot CPU buffers. Simply remove that change. - Clear all CPU buffers when starting tracing in a boot mapped buffer To properly process events from a previous boot, the address space needs to be accounted for due to KASLR and the events in the buffer are updated accordingly when read. This also requires that when the buffer has tracing enabled again in the current boot that the buffers are reset so that events from the previous boot do not interact with the events of the current boot and cause confusing due to not having the proper meta data. It was found that if a CPU is taken offline, that its per CPU buffer is not reset when tracing starts. This allows for events to be from both the previous boot and the current boot to be in the buffer at the same time. Clear all CPU buffers when tracing is started in a boot mapped buffer. -----BEGIN PGP SIGNATURE----- iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCZzdr5hQccm9zdGVkdEBn b29kbWlzLm9yZwAKCRAp5XQQmuv6qq3gAQDsqNNld3D3wW72VMJ52d9zdBXFUdrV hbszve+PSj/wuAD/TeCp0BcI8Az+G7/enMXnlEugLo3XKLr/YvPQ3nlb8QA= =VR4z -----END PGP SIGNATURE----- Merge tag 'trace-ringbuffer-v6.12-rc7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull ring buffer fixes from Steven Rostedt: - Revert: "ring-buffer: Do not have boot mapped buffers hook to CPU hotplug" A crash that happened on cpu hotplug was actually caused by the incorrect ref counting that was fixed by commit2cf9733891
("ring-buffer: Fix refcount setting of boot mapped buffers"). The removal of calling cpu hotplug callbacks on memory mapped buffers was not an issue even though the tests at the time pointed toward it. But in fact, there's a check in that code that tests to see if the buffers are already allocated or not, and will not allocate them again if they are. Not calling the cpu hotplug callbacks ended up not initializing the non boot CPU buffers. Simply remove that change. - Clear all CPU buffers when starting tracing in a boot mapped buffer To properly process events from a previous boot, the address space needs to be accounted for due to KASLR and the events in the buffer are updated accordingly when read. This also requires that when the buffer has tracing enabled again in the current boot that the buffers are reset so that events from the previous boot do not interact with the events of the current boot and cause confusing due to not having the proper meta data. It was found that if a CPU is taken offline, that its per CPU buffer is not reset when tracing starts. This allows for events to be from both the previous boot and the current boot to be in the buffer at the same time. Clear all CPU buffers when tracing is started in a boot mapped buffer. * tag 'trace-ringbuffer-v6.12-rc7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/ring-buffer: Clear all memory mapped CPU ring buffers on first recording Revert: "ring-buffer: Do not have boot mapped buffers hook to CPU hotplug"
This commit is contained in:
commit
b5a24181e4
@ -2337,12 +2337,9 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
|
|||||||
if (!buffer->buffers[cpu])
|
if (!buffer->buffers[cpu])
|
||||||
goto fail_free_buffers;
|
goto fail_free_buffers;
|
||||||
|
|
||||||
/* If already mapped, do not hook to CPU hotplug */
|
|
||||||
if (!start) {
|
|
||||||
ret = cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node);
|
ret = cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail_free_buffers;
|
goto fail_free_buffers;
|
||||||
}
|
|
||||||
|
|
||||||
mutex_init(&buffer->mutex);
|
mutex_init(&buffer->mutex);
|
||||||
|
|
||||||
|
@ -2386,6 +2386,25 @@ void tracing_reset_online_cpus(struct array_buffer *buf)
|
|||||||
ring_buffer_record_enable(buffer);
|
ring_buffer_record_enable(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tracing_reset_all_cpus(struct array_buffer *buf)
|
||||||
|
{
|
||||||
|
struct trace_buffer *buffer = buf->buffer;
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ring_buffer_record_disable(buffer);
|
||||||
|
|
||||||
|
/* Make sure all commits have finished */
|
||||||
|
synchronize_rcu();
|
||||||
|
|
||||||
|
buf->time_start = buffer_ftrace_now(buf, buf->cpu);
|
||||||
|
|
||||||
|
ring_buffer_reset(buffer);
|
||||||
|
|
||||||
|
ring_buffer_record_enable(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/* Must have trace_types_lock held */
|
/* Must have trace_types_lock held */
|
||||||
void tracing_reset_all_online_cpus_unlocked(void)
|
void tracing_reset_all_online_cpus_unlocked(void)
|
||||||
{
|
{
|
||||||
@ -6145,8 +6164,13 @@ static void update_last_data(struct trace_array *tr)
|
|||||||
if (!tr->text_delta && !tr->data_delta)
|
if (!tr->text_delta && !tr->data_delta)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Clear old data */
|
/*
|
||||||
tracing_reset_online_cpus(&tr->array_buffer);
|
* Need to clear all CPU buffers as there cannot be events
|
||||||
|
* from the previous boot mixed with events with this boot
|
||||||
|
* as that will cause a confusing trace. Need to clear all
|
||||||
|
* CPU buffers, even for those that may currently be offline.
|
||||||
|
*/
|
||||||
|
tracing_reset_all_cpus(&tr->array_buffer);
|
||||||
|
|
||||||
/* Using current data now */
|
/* Using current data now */
|
||||||
tr->text_delta = 0;
|
tr->text_delta = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user