From: Mathieu Desnoyers Date: Sun, 25 Sep 2016 15:00:08 +0000 (-0400) Subject: Performance: Relax atomicity constraints for crash handling X-Git-Tag: v2.9.0-rc1~14 X-Git-Url: http://git.liburcu.org/?p=lttng-modules.git;a=commitdiff_plain;h=6212b6b6ae1db7f267bcbd017737ac6dfa9ffe16 Performance: Relax atomicity constraints for crash handling 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 --- diff --git a/lib/ringbuffer/frontend_internal.h b/lib/ringbuffer/frontend_internal.h index 32785853..a2efee79 100644 --- a/lib/ringbuffer/frontend_internal.h +++ b/lib/ringbuffer/frontend_internal.h @@ -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,