ring-buffer: do not swap buffers during a commit
If a commit is taking place on a CPU ring buffer, do not allow it to be swapped. Return -EBUSY when this is detected instead. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Родитель
41b6a95d69
Коммит
98277991a9
|
@ -3519,16 +3519,23 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
|
||||||
atomic_inc(&cpu_buffer_a->record_disabled);
|
atomic_inc(&cpu_buffer_a->record_disabled);
|
||||||
atomic_inc(&cpu_buffer_b->record_disabled);
|
atomic_inc(&cpu_buffer_b->record_disabled);
|
||||||
|
|
||||||
|
ret = -EBUSY;
|
||||||
|
if (local_read(&cpu_buffer_a->committing))
|
||||||
|
goto out_dec;
|
||||||
|
if (local_read(&cpu_buffer_b->committing))
|
||||||
|
goto out_dec;
|
||||||
|
|
||||||
buffer_a->buffers[cpu] = cpu_buffer_b;
|
buffer_a->buffers[cpu] = cpu_buffer_b;
|
||||||
buffer_b->buffers[cpu] = cpu_buffer_a;
|
buffer_b->buffers[cpu] = cpu_buffer_a;
|
||||||
|
|
||||||
cpu_buffer_b->buffer = buffer_a;
|
cpu_buffer_b->buffer = buffer_a;
|
||||||
cpu_buffer_a->buffer = buffer_b;
|
cpu_buffer_a->buffer = buffer_b;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out_dec:
|
||||||
atomic_dec(&cpu_buffer_a->record_disabled);
|
atomic_dec(&cpu_buffer_a->record_disabled);
|
||||||
atomic_dec(&cpu_buffer_b->record_disabled);
|
atomic_dec(&cpu_buffer_b->record_disabled);
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче