On 05/28/2018 04:15 PM, Gavin Hu wrote:

  do {
+const uint32_t cons_tail = r->cons.tail;
+
  /* Reset n to the initial burst count */
  n = max;

  *old_head = __atomic_load_n(&r->prod.head,
  __ATOMIC_ACQUIRE);
-const uint32_t cons_tail = r->cons.tail;
+
[Gavin Hu] The ACQUIRE and RELEASE pair protects anything that between the two 
must be visible to other threads when they perform an acquire operation on the 
same memory address. Your changes broke this semantics.  I advise to move the 
declaration before and keep the assignment in the old place.

I see, thanks for the tip.

How about just get rid of this temp altogether if access to it is locked during this sequence anyway? It's not like we had to sample it after the lock then, or it's bringing anything else to the party.

So instead of cons_tail / prod_tail at all, replace directly with r->cons.tail / r->prod.tail at the single usage for each.

-Andy

Reply via email to