On Mon, Apr 25, 2016 at 11:04:38AM -0700, Vikas Shivappa wrote: > >This is a 'creative' solution; why don't you do the normal thing, which > >is: > > > >start: > > prev_count = read_hw_counter(); > > > >read: > > do { > > prev = prev_count; > > cur_val = read_hw_counter(); > > delta = cur_val - prev; > > } while (local_cmpxchg(&prev_count, prev, cur_val) != prev); > > count += delta; > > > I may need to update the comment. > > rc_count stores the total bytes for RMIDs that were used for this event > except for the count of current RMID.
Yeah, I got that, eventually. > Say an event used RMID(1) .. RMID(k) from init to read and it had RMID(k) > when read was called, the rc_count stores the values read from RMID1 .. > RMID(k-1). > > For MBM the patch is trying to do: > count > = total_bytes of RMID(1) + ... +total_bytes of RMID(k-1) + total_bytes of > RMID(k)) > = rc_count + total_bytes of RMID(k). How is the regular counting scheme as outlined above not dealing with this properly?