History

ring-buffer: Move disabled check into preempt disable section

The ring buffer resizing and resetting relies on a schedule RCU action. The buffers are disabled, a synchronize_sched() is called and then the resize or reset takes place. But this only works if the disabling of the buffers are within the preempt disabled section, otherwise a window exists that the buffers can be written to while a reset or resize takes place.

Lai Jiangshan committed 16 years ago

Commit 52fbe9c1 parent 915a0b51 file · +6 −6Browse files

Unified · Split

kernel/trace/ring_buffer.c+6−6
@@ -2232,12 +2232,12 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, unsigned long length) · 2231 unmodified lines
22322232 if (ring_buffer_flags != RB_BUFFERS_ON)
22332233 return NULL;
22342234
2235− if (atomic_read(&buffer->record_disabled))
2236− return NULL;
2237−
22382235 /* If we are tracing schedule, we don't want to recurse */
22392236 resched = ftrace_preempt_disable();
22402237
2238+ if (atomic_read(&buffer->record_disabled))
2239+ goto out_nocheck;
2240+
22412241 if (trace_recursive_lock())
22422242 goto out_nocheck;
22432243
@@ -2469,11 +2469,11 @@ int ring_buffer_write(struct ring_buffer *buffer, · 225 unmodified lines
24692469 if (ring_buffer_flags != RB_BUFFERS_ON)
24702470 return -EBUSY;
24712471
2472− if (atomic_read(&buffer->record_disabled))
2473− return -EBUSY;
2474−
24752472 resched = ftrace_preempt_disable();
24762473
2474+ if (atomic_read(&buffer->record_disabled))
2475+ goto out;
2476+
24772477 cpu = raw_smp_processor_id();
24782478
24792479 if (!cpumask_test_cpu(cpu, buffer->cpumask))

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