Performance: Relax atomicity constraints for crash handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 25 Sep 2016 15:00:08 +0000 (11:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 25 Sep 2016 15:00:08 +0000 (11:00 -0400)
Use a store rather than a cmpxchg() for the update of the
sequential commit counter. This speeds up commit. The downside
is that short race windows between the if() check to see if the
counter is larger than the new value and the update could result
in the counter going backwards, in unlikely preemption or signal
delivery scenarios.

Accept that we may lose a few events in a crash dump for the
benefit of tracing speed.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/frontend_internal.h

index 32785853b721bb3a6d0aebedce45607bab8efb0b..a2efee79a2f7f1ddcbc9ab31f5a7516ff5704cc0 100644 (file)
@@ -307,9 +307,8 @@ void lib_ring_buffer_write_commit_counter(const struct lib_ring_buffer_config *c
                return;
 
        commit_seq_old = v_read(config, &buf->commit_hot[idx].seq);
-       while ((long) (commit_seq_old - commit_count) < 0)
-               commit_seq_old = v_cmpxchg(config, &buf->commit_hot[idx].seq,
-                                          commit_seq_old, commit_count);
+       if (likely((long) (commit_seq_old - commit_count) < 0))
+               v_set(config, &buf->commit_hot[idx].seq, commit_count);
 }
 
 extern int lib_ring_buffer_create(struct lib_ring_buffer *buf,
This page took 0.027291 seconds and 4 git commands to generate.