Fix: ring buffer: handle concurrent update in nested buffer wrap around check
[lttng-ust.git] / libringbuffer / frontend_internal.h
index 2d3b1071f9e4f10565ca52b0385c65359a8866f2..2f837f7d80134449816afcb3e97546bd311aea0e 100644 (file)
@@ -341,6 +341,12 @@ void lib_ring_buffer_check_deliver(const struct lttng_ust_lib_ring_buffer_config
                 * The subbuffer size is least 2 bytes (minimum size: 1 page).
                 * This guarantees that old_commit_count + 1 != commit_count.
                 */
+
+               /*
+                * Order prior updates to reserve count prior to the
+                * commit_cold cc_sb update.
+                */
+               cmm_smp_wmb();
                if (caa_likely(v_cmpxchg(config, &shmp_index(handle, buf->commit_cold, idx)->cc_sb,
                                         old_commit_count, old_commit_count + 1)
                           == old_commit_count)) {
@@ -386,6 +392,11 @@ void lib_ring_buffer_check_deliver(const struct lttng_ust_lib_ring_buffer_config
                        /* End of exclusive subbuffer access */
                        v_set(config, &shmp_index(handle, buf->commit_cold, idx)->cc_sb,
                              commit_count);
+                       /*
+                        * Order later updates to reserve count after
+                        * the commit cold cc_sb update.
+                        */
+                       cmm_smp_wmb();
                        lib_ring_buffer_vmcore_check_deliver(config, buf,
                                                 commit_count, idx, handle);
 
This page took 0.023668 seconds and 4 git commands to generate.