History

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 commit 2cf9733891a4 ("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"

Linus Torvalds committed 1 year ago

Commit b5a24182 parents e8bdb3c 09663752 files · +29 −8Browse files

Unified · Split

2 files
  1. kernel/trace/ring_buffer.c +3 −6
  2. kernel/trace/trace.c +26 −2
kernel/trace/ring_buffer.c+3−6
@@ -2337,12 +2337,9 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags, · 2336 unmodified lines
2337 if (!buffer->buffers[cpu])2337 if (!buffer->buffers[cpu])
2338 goto fail_free_buffers;2338 goto fail_free_buffers;
2339 2339
2340 /* If already mapped, do not hook to CPU hotplug */2340 ret = cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node);
2341 if (!start) {2341 if (ret < 0)
2342 ret = cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node);2342 goto fail_free_buffers;
2343 if (ret < 0)
2344 goto fail_free_buffers;
2345 }
2346 2343
2347 mutex_init(&buffer->mutex);2344 mutex_init(&buffer->mutex);
2348 2345
kernel/trace/trace.c+26−2
@@ -2386,6 +2386,25 @@ void tracing_reset_online_cpus(struct array_buffer *buf) · 2385 unmodified lines
2386 ring_buffer_record_enable(buffer);2386 ring_buffer_record_enable(buffer);
2387}2387}
2388 2388
2389static void tracing_reset_all_cpus(struct array_buffer *buf)
2390{
2391 struct trace_buffer *buffer = buf->buffer;
2392
2393 if (!buffer)
2394 return;
2395
2396 ring_buffer_record_disable(buffer);
2397
2398 /* Make sure all commits have finished */
2399 synchronize_rcu();
2400
2401 buf->time_start = buffer_ftrace_now(buf, buf->cpu);
2402
2403 ring_buffer_reset(buffer);
2404
2405 ring_buffer_record_enable(buffer);
2406}
2407
2389/* Must have trace_types_lock held */2408/* Must have trace_types_lock held */
2390void tracing_reset_all_online_cpus_unlocked(void)2409void tracing_reset_all_online_cpus_unlocked(void)
2391{2410{
@@ -6145,8 +6164,13 @@ static void update_last_data(struct trace_array *tr) · 3753 unmodified lines
6145 if (!tr->text_delta && !tr->data_delta)6164 if (!tr->text_delta && !tr->data_delta)
6146 return;6165 return;
6147 6166
6148 /* Clear old data */6167 /*
6149 tracing_reset_online_cpus(&tr->array_buffer);6168 * Need to clear all CPU buffers as there cannot be events
6169 * from the previous boot mixed with events with this boot
6170 * as that will cause a confusing trace. Need to clear all
6171 * CPU buffers, even for those that may currently be offline.
6172 */
6173 tracing_reset_all_cpus(&tr->array_buffer);
6150 6174
6151 /* Using current data now */6175 /* Using current data now */
6152 tr->text_delta = 0;6176 tr->text_delta = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t