From: Mathieu Desnoyers Date: Fri, 13 May 2011 12:00:14 +0000 (-0400) Subject: Use -EIO as tsc value for nmi error (and drop event) X-Git-Tag: v2.0-pre1~156 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=97ca2c5484815a67b70fcf2b1772eb1b2c2e5633;p=lttng-modules.git Use -EIO as tsc value for nmi error (and drop event) Signed-off-by: Mathieu Desnoyers --- diff --git a/lib/ringbuffer/frontend_api.h b/lib/ringbuffer/frontend_api.h index d55eb33e..8a58ace4 100644 --- a/lib/ringbuffer/frontend_api.h +++ b/lib/ringbuffer/frontend_api.h @@ -82,6 +82,8 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config, *o_old = *o_begin; ctx->tsc = lib_ring_buffer_clock_read(chan); + if ((int64_t) ctx->tsc == -EIO) + return 1; /* * Prefetch cacheline for read because we have to read the previous @@ -130,8 +132,12 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config, * Atomic wait-free slot reservation. The reserved space starts at the context * "pre_offset". Its length is "slot_size". The associated time-stamp is "tsc". * - * Return : -ENOSPC if not enough space, -EAGAIN if channel is disabled. - * Returns 0 on success. + * Return : + * 0 on success. + * -EAGAIN if channel is disabled. + * -ENOSPC if event size is too large for packet. + * -ENOBUFS if there is currently not enough space in buffer for the event. + * -EIO if data cannot be written into the buffer for any other reason. */ static inline diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c index d48d66b3..9a90997c 100644 --- a/lib/ringbuffer/ring_buffer_frontend.c +++ b/lib/ringbuffer/ring_buffer_frontend.c @@ -1482,7 +1482,9 @@ EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_slow); /* * Returns : * 0 if ok - * !0 if execution must be aborted. + * -ENOSPC if event size is too large for packet. + * -ENOBUFS if there is currently not enough space in buffer for the event. + * -EIO if data cannot be written into the buffer for any other reason. */ static int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, @@ -1501,6 +1503,8 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, offsets->pre_header_padding = 0; ctx->tsc = config->cb.ring_buffer_clock_read(chan); + if ((int64_t) ctx->tsc == -EIO) + return -EIO; if (last_tsc_overflow(config, buf, ctx->tsc)) ctx->rflags = RING_BUFFER_RFLAG_FULL_TSC; @@ -1553,7 +1557,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, * and we are full : record is lost. */ v_inc(config, &buf->records_lost_full); - return -1; + return -ENOBUFS; } else { /* * Next subbuffer not being written to, and we @@ -1570,7 +1574,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, * many nested writes over a reserve/commit pair. */ v_inc(config, &buf->records_lost_wrap); - return -1; + return -EIO; } offsets->size = config->cb.record_header_size(config, chan, @@ -1589,7 +1593,7 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, * complete the sub-buffer switch. */ v_inc(config, &buf->records_lost_big); - return -1; + return -ENOSPC; } else { /* * We just made a successful buffer switch and the @@ -1618,7 +1622,8 @@ int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf, * lib_ring_buffer_reserve_slow - Atomic slot reservation in a buffer. * @ctx: ring buffer context. * - * Return : -ENOSPC if not enough space, else returns 0. + * Return : -NOBUFS if not enough space, -ENOSPC if event size too large, + * -EIO for other errors, else returns 0. * It will take care of sub-buffer switching. */ int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx) @@ -1637,9 +1642,10 @@ int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx) offsets.size = 0; do { - if (unlikely(lib_ring_buffer_try_reserve_slow(buf, chan, &offsets, - ctx))) - return -ENOSPC; + ret = lib_ring_buffer_try_reserve_slow(buf, chan, &offsets, + ctx); + if (unlikely(ret)) + return ret; } while (unlikely(v_cmpxchg(config, &buf->offset, offsets.old, offsets.end) != offsets.old)); diff --git a/wrapper/trace-clock.h b/wrapper/trace-clock.h index 18cda2aa..b2a90bd4 100644 --- a/wrapper/trace-clock.h +++ b/wrapper/trace-clock.h @@ -28,7 +28,7 @@ static inline u64 trace_clock_monotonic_wrapper(void) * nest over the xtime write seqlock and deadlock. */ if (in_nmi()) - return 0; + return (u64) -EIO; ktime = ktime_get(); return (u64) ktime.tv64;