88
* Last TSC comparison functions. Check if the current TSC overflows tsc_bits
89
* bits from the last TSC read. When overflows are detected, the full 64-bit
90
* timestamp counter should be written in the record header. Reads and writes
91
* last_tsc atomically.
88
* Last timestamp comparison functions. Check if the current timestamp overflows
89
* timestamp_bits bits from the last timestamp read. When overflows are
90
* detected, the full 64-bit timestamp counter should be written in the record
91
* header. Reads and writes last_timestamp atomically.
94
94
#if (CAA_BITS_PER_LONG == 32)
96
void save_last_tsc(const struct lttng_ust_ring_buffer_config *config,
97
struct lttng_ust_ring_buffer *buf, uint64_t tsc)
96
void save_last_timestamp(const struct lttng_ust_ring_buffer_config *config,
97
struct lttng_ust_ring_buffer *buf, uint64_t timestamp)
99
if (config->tsc_bits == 0 || config->tsc_bits == 64)
99
if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
103
103
* Ensure the compiler performs this update in a single instruction.
105
v_set(config, &buf->last_tsc, (unsigned long)(tsc >> config->tsc_bits));
105
v_set(config, &buf->last_timestamp, (unsigned long)(timestamp >> config->timestamp_bits));
109
int last_tsc_overflow(const struct lttng_ust_ring_buffer_config *config,
110
struct lttng_ust_ring_buffer *buf, uint64_t tsc)
109
int last_timestamp_overflow(const struct lttng_ust_ring_buffer_config *config,
110
struct lttng_ust_ring_buffer *buf, uint64_t timestamp)
112
unsigned long tsc_shifted;
112
unsigned long timestamp_shifted;
114
if (config->tsc_bits == 0 || config->tsc_bits == 64)
114
if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
117
tsc_shifted = (unsigned long)(tsc >> config->tsc_bits);
118
if (caa_unlikely(tsc_shifted
119
- (unsigned long)v_read(config, &buf->last_tsc)))
117
timestamp_shifted = (unsigned long)(timestamp >> config->timestamp_bits);
118
if (caa_unlikely(timestamp_shifted
119
- (unsigned long)v_read(config, &buf->last_timestamp)))
126
void save_last_tsc(const struct lttng_ust_ring_buffer_config *config,
127
struct lttng_ust_ring_buffer *buf, uint64_t tsc)
126
void save_last_timestamp(const struct lttng_ust_ring_buffer_config *config,
127
struct lttng_ust_ring_buffer *buf, uint64_t timestamp)
129
if (config->tsc_bits == 0 || config->tsc_bits == 64)
129
if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
132
v_set(config, &buf->last_tsc, (unsigned long)tsc);
132
v_set(config, &buf->last_timestamp, (unsigned long)timestamp);
136
int last_tsc_overflow(const struct lttng_ust_ring_buffer_config *config,
137
struct lttng_ust_ring_buffer *buf, uint64_t tsc)
136
int last_timestamp_overflow(const struct lttng_ust_ring_buffer_config *config,
137
struct lttng_ust_ring_buffer *buf, uint64_t timestamp)
139
if (config->tsc_bits == 0 || config->tsc_bits == 64)
139
if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
142
if (caa_unlikely((tsc - v_read(config, &buf->last_tsc))
143
>> config->tsc_bits))
142
if (caa_unlikely((timestamp - v_read(config, &buf->last_timestamp))
143
>> config->timestamp_bits))