} __packed;
struct hws_trailer_entry {
- unsigned int f:1; /* 0 - Block Full Indicator */
- unsigned int a:1; /* 1 - Alert request control */
- unsigned int t:1; /* 2 - Timestamp format */
- unsigned long long:61; /* 3 - 63: Reserved */
+ union {
+ struct {
+ unsigned int f:1; /* 0 - Block Full Indicator */
+ unsigned int a:1; /* 1 - Alert request control */
+ unsigned int t:1; /* 2 - Timestamp format */
+ unsigned long long:61; /* 3 - 63: Reserved */
+ };
+ unsigned long long flags; /* 0 - 63: All indicators */
+ };
unsigned long long overflow; /* 64 - sample Overflow count */
unsigned long long timestamp; /* 16 - time-stamp */
unsigned long long timestamp1; /* */
struct hw_perf_event *hwc = &event->hw;
struct hws_trailer_entry *te;
unsigned long *sdbt;
- unsigned long long event_overflow, sampl_overflow, num_sdb;
+ unsigned long long event_overflow, sampl_overflow, num_sdb, te_flags;
int done;
sdbt = (unsigned long *) TEAR_REG(hwc);
hw_collect_samples(event, sdbt, &event_overflow);
num_sdb++;
- /* Reset trailer */
- xchg(&te->overflow, 0);
- xchg((unsigned char *) te, 0x40);
+ /* Reset trailer (using compare-double-and-swap) */
+ do {
+ te_flags = te->flags & ~SDB_TE_BUFFER_FULL_MASK;
+ te_flags |= SDB_TE_ALERT_REQ_MASK;
+ } while (!cmpxchg_double(&te->flags, &te->overflow,
+ te->flags, te->overflow,
+ te_flags, 0ULL));
/* Advance to next sample-data-block */
sdbt++;