@@ -252,6 +252,11 @@ mpsc_queue::try_consume(Function &&f)
252252
253253 size_t offset;
254254 size_t len = ringbuf_consume (ring_buffer.get (), &offset);
255+
256+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
257+ ANNOTATE_HAPPENS_AFTER (ring_buffer.get ());
258+ #endif
259+
255260 if (len != 0 ) {
256261 pmem->written = offset;
257262 pop.persist (pmem->written );
@@ -264,6 +269,10 @@ mpsc_queue::try_consume(Function &&f)
264269 if (elements_to_consume)
265270 f (acc);
266271
272+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
273+ ANNOTATE_HAPPENS_BEFORE (ring_buffer.get ());
274+ #endif
275+
267276 ringbuf_release (ring_buffer.get (), len);
268277
269278 /* XXX: it would be better to call f once - hide
@@ -280,6 +289,13 @@ inline mpsc_queue::worker::worker(mpsc_queue *q)
280289{
281290 queue = q;
282291 auto &manager = queue->get_id_manager ();
292+
293+ #if LIBPMEMOBJ_CPP_VG_DRD_ENABLED
294+ ANNOTATE_BENIGN_RACE_SIZED (
295+ &manager, sizeof (std::mutex),
296+ " https://bugs.kde.org/show_bug.cgi?id=416286" );
297+ #endif
298+
283299 id = manager.get ();
284300
285301 assert (id < q->ring_buffer ->nworkers );
@@ -330,6 +346,10 @@ mpsc_queue::worker::try_produce(size_t size, Function &&f)
330346 pmem::detail::CACHELINE_SIZE);
331347 auto offset = ringbuf_acquire (queue->ring_buffer .get (), w, req_size);
332348
349+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
350+ ANNOTATE_HAPPENS_AFTER (queue->ring_buffer .get ());
351+ #endif
352+
333353 if (offset == -1 )
334354 return false ;
335355
@@ -342,6 +362,10 @@ mpsc_queue::worker::try_produce(size_t size, Function &&f)
342362 store_to_log (pmem::obj::string_view (data.get (), size),
343363 queue->buf + offset);
344364
365+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
366+ ANNOTATE_HAPPENS_BEFORE (queue->ring_buffer .get ());
367+ #endif
368+
345369 ringbuf_produce (queue->ring_buffer .get (), w);
346370
347371 return true ;
@@ -355,11 +379,19 @@ mpsc_queue::worker::try_produce(pmem::obj::string_view data)
355379 pmem::detail::CACHELINE_SIZE);
356380 auto offset = ringbuf_acquire (queue->ring_buffer .get (), w, req_size);
357381
382+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
383+ ANNOTATE_HAPPENS_AFTER (queue->ring_buffer .get ());
384+ #endif
385+
358386 if (offset == -1 )
359387 return false ;
360388
361389 store_to_log (data, queue->buf + offset);
362390
391+ #if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
392+ ANNOTATE_HAPPENS_BEFORE (queue->ring_buffer .get ());
393+ #endif
394+
363395 ringbuf_produce (queue->ring_buffer .get (), w);
364396
365397 return true ;
0 commit comments