X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=ltt-usertrace%2Fltt%2Fltt-usertrace-fast.h;h=fb01893684259d7ab09bbab69610e792f25ed22b;hb=2786770231bafe751b79ee829519b6d74a4d7709;hp=5bcec27db93e91feabbaee6a11ededa1a9a24d38;hpb=1e6e693aad9af55fb3a4722c862edefd31896bbb;p=lttv.git diff --git a/ltt-usertrace/ltt/ltt-usertrace-fast.h b/ltt-usertrace/ltt/ltt-usertrace-fast.h index 5bcec27d..fb018936 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-fast.h +++ b/ltt-usertrace/ltt/ltt-usertrace-fast.h @@ -53,7 +53,7 @@ extern "C" { #define LTT_TRACER_MAGIC_NUMBER 0x00D6B7ED #define LTT_TRACER_VERSION_MAJOR 0 -#define LTT_TRACER_VERSION_MINOR 7 +#define LTT_TRACER_VERSION_MINOR 8 #ifndef atomic_cmpxchg #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) @@ -71,12 +71,14 @@ struct ltt_trace_header { uint8_t flight_recorder; uint8_t has_heartbeat; uint8_t has_alignment; /* Event header alignment */ + uint8_t tsc_lsb_truncate; + uint8_t tscbits; uint32_t freq_scale; uint64_t start_freq; uint64_t start_tsc; uint64_t start_monotonic; - uint64_t start_time_sec; - uint64_t start_time_usec; + uint64_t start_time_sec; + uint64_t start_time_usec; } __attribute((packed)); @@ -367,7 +369,6 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( int commit_count, reserve_count; int ret; sigset_t oldset, set; - int signals_disabled = 0; do { offset_old = atomic_read(<t_buf->offset); @@ -417,16 +418,28 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( { /* sem_wait is not signal safe. Disable signals around it. * Signals are kept disabled to make sure we win the cmpxchg. */ - /* Disable signals */ - if(!signals_disabled) { - ret = sigfillset(&set); - if(ret) perror("LTT Error in sigfillset\n"); - - ret = pthread_sigmask(SIG_BLOCK, &set, &oldset); + ret = sigfillset(&set); + if(ret) perror("LTT Error in sigfillset\n"); + + ret = pthread_sigmask(SIG_BLOCK, &set, &oldset); + if(ret) perror("LTT Error in pthread_sigmask\n"); + + /* We detect if a signal came between + * the offset read and signal disabling: + * if it is the case, then we restart + * the loop after reenabling signals. It + * means that it's a signal that has + * won the buffer switch.*/ + if(offset_old != atomic_read(<t_buf->offset)) { + ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL); if(ret) perror("LTT Error in pthread_sigmask\n"); - signals_disabled = 1; + continue; } + /* If the offset is still the same, then + * we can safely proceed to do the + * buffer switch without being + * interrupted by a signal. */ sem_wait(<t_buf->writer_sem); } @@ -550,7 +563,7 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( * sem_wait does in fact win the cmpxchg for the offset. We only call * these system calls on buffer boundaries because of their performance * cost. */ - if(signals_disabled) { + if(reserve_commit_diff == 0) { ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL); if(ret) perror("LTT Error in pthread_sigmask\n"); }